@@ -37,6 +37,38 @@ describe("task_await tool", () => {
3737 } ) ;
3838 } ) ;
3939
40+ it ( "supports filterDescendantAgentTaskIds without losing this binding" , async ( ) => {
41+ using tempDir = new TestTempDir ( "test-task-await-tool-this-binding" ) ;
42+ const baseConfig = createTestToolConfig ( tempDir . path , { workspaceId : "parent-workspace" } ) ;
43+
44+ const waitForAgentReport = mock ( ( ) => Promise . resolve ( { reportMarkdown : "ok" } ) ) ;
45+ const isDescendantAgentTask = mock ( ( ) => true ) ;
46+
47+ const taskService = {
48+ filterDescendantAgentTaskIds : function ( ancestorWorkspaceId : string , taskIds : string [ ] ) {
49+ expect ( this ) . toBe ( taskService ) ;
50+ expect ( ancestorWorkspaceId ) . toBe ( "parent-workspace" ) ;
51+ expect ( taskIds ) . toEqual ( [ "t1" ] ) ;
52+ return taskIds ;
53+ } ,
54+ listActiveDescendantAgentTaskIds : mock ( ( ) => [ ] ) ,
55+ isDescendantAgentTask,
56+ waitForAgentReport,
57+ } as unknown as TaskService ;
58+
59+ const tool = createTaskAwaitTool ( { ...baseConfig , taskService } ) ;
60+
61+ const result : unknown = await Promise . resolve (
62+ tool . execute ! ( { task_ids : [ "t1" ] } , mockToolCallOptions )
63+ ) ;
64+
65+ expect ( result ) . toEqual ( {
66+ results : [ { status : "completed" , taskId : "t1" , reportMarkdown : "ok" , title : undefined } ] ,
67+ } ) ;
68+ expect ( isDescendantAgentTask ) . toHaveBeenCalledTimes ( 0 ) ;
69+ expect ( waitForAgentReport ) . toHaveBeenCalledTimes ( 1 ) ;
70+ } ) ;
71+
4072 it ( "marks invalid_scope without calling waitForAgentReport" , async ( ) => {
4173 using tempDir = new TestTempDir ( "test-task-await-tool-invalid-scope" ) ;
4274 const baseConfig = createTestToolConfig ( tempDir . path , { workspaceId : "parent-workspace" } ) ;
0 commit comments