@@ -66,6 +66,36 @@ describe("BatchTool: file lessons", () => {
6666 } )
6767} )
6868
69+ describe ( "BatchTool: inner tool context" , ( ) => {
70+ test ( "carries the turn's workspace and token to the inner tools" , async ( ) => {
71+ const tool = await getToolInfo ( )
72+ let seen : { workspaceId ?: number ; turn ?: number } | undefined
73+ const registry = spyOn ( ToolRegistry , "tools" ) . mockResolvedValue ( [ {
74+ id : "probe" ,
75+ registrySource : undefined ,
76+ description : "captures its context" ,
77+ parameters : Schema . Unknown ,
78+ execute : ( _args : unknown , ctx : { workspaceId ?: number ; turn ?: number } ) => {
79+ seen = { workspaceId : ctx . workspaceId , turn : ctx . turn }
80+ return Effect . succeed ( { title : "ok" , output : "ok" , metadata : { } } )
81+ } ,
82+ } ] as any )
83+ const updatePart = Object . assign ( async ( part : Parameters < typeof Session . updatePart > [ 0 ] ) => part , Session . updatePart )
84+ const updates = spyOn ( Session , "updatePart" ) . mockImplementation ( updatePart )
85+ try {
86+ const result = await tool . execute ( { tool_calls : [ { tool : "probe" , parameters : { } } ] } , {
87+ sessionID : SessionID . make ( "ses_batch_ctx" ) , messageID : MessageID . make ( "msg_batch_ctx" ) , agent : "build" ,
88+ abort : AbortSignal . any ( [ ] ) , messages : [ ] , extra : { } , workspaceId : 7 , turn : 3 ,
89+ } as any )
90+ expect ( result . metadata . successful ) . toBe ( 1 )
91+ expect ( seen ) . toEqual ( { workspaceId : 7 , turn : 3 } )
92+ } finally {
93+ updates . mockRestore ( )
94+ registry . mockRestore ( )
95+ }
96+ } )
97+ } )
98+
6999describe ( "BatchTool: schema validation" , ( ) => {
70100 test ( "rejects empty tool_calls array" , async ( ) => {
71101 const tool = await getToolInfo ( )
0 commit comments