@@ -1910,6 +1910,7 @@ describe("runCopilotAttempt", () => {
19101910 it ( "retains a timed-out session until later compaction reaches session.idle" , async ( ) => {
19111911 const afterCompaction = vi . fn ( ) ;
19121912 const onDeferredCompaction = vi . fn ( ) ;
1913+ const cleanupToolBridge = vi . fn ( ) ;
19131914 initializeGlobalHookRunner (
19141915 createMockPluginRegistry ( [ { hookName : "after_compaction" , handler : afterCompaction } ] ) ,
19151916 ) ;
@@ -1922,8 +1923,14 @@ describe("runCopilotAttempt", () => {
19221923 ) ;
19231924 } ,
19241925 } ) ;
1926+ const createToolBridge = vi . fn ( async ( ) => ( {
1927+ cleanup : cleanupToolBridge ,
1928+ sdkTools : [ ] ,
1929+ sourceTools : [ ] ,
1930+ } ) ) ;
19251931
19261932 const result = await runCopilotAttempt ( makeParams ( ) , {
1933+ createToolBridge,
19271934 onDeferredCompaction,
19281935 pool : makeFakePool ( sdk ) ,
19291936 } ) ;
@@ -1933,6 +1940,7 @@ describe("runCopilotAttempt", () => {
19331940 expect ( onDeferredCompaction ) . toHaveBeenCalledWith (
19341941 expect . objectContaining ( { sdkSessionId : "sess-1" } ) ,
19351942 ) ;
1943+ expect ( cleanupToolBridge ) . not . toHaveBeenCalled ( ) ;
19361944 expect ( activeSession ?. disconnect ) . not . toHaveBeenCalled ( ) ;
19371945
19381946 activeSession ?. emit ( "session.compaction_start" , { } ) ;
@@ -1946,6 +1954,7 @@ describe("runCopilotAttempt", () => {
19461954 await vi . waitFor ( ( ) => {
19471955 expect ( activeSession ?. disconnect ) . toHaveBeenCalledTimes ( 1 ) ;
19481956 } ) ;
1957+ expect ( cleanupToolBridge ) . toHaveBeenCalledTimes ( 1 ) ;
19491958 } ) ;
19501959
19511960 it ( "does not mark a timeout after SDK compaction has completed as active compaction" , async ( ) => {
@@ -3150,7 +3159,6 @@ describe("runCopilotAttempt", () => {
31503159 expect ( readAvailableTools ( sdk . createSession . mock . calls [ 0 ] ) ) . toEqual ( [
31513160 "read" ,
31523161 "edit" ,
3153- "ask_user" ,
31543162 "builtin:ask_user" ,
31553163 ] ) ;
31563164 } ) ;
@@ -3168,10 +3176,7 @@ describe("runCopilotAttempt", () => {
31683176
31693177 await runCopilotAttempt ( makeParams ( ) , { createToolBridge, pool } ) ;
31703178
3171- expect ( readAvailableTools ( sdk . createSession . mock . calls [ 0 ] ) ) . toEqual ( [
3172- "ask_user" ,
3173- "builtin:ask_user" ,
3174- ] ) ;
3179+ expect ( readAvailableTools ( sdk . createSession . mock . calls [ 0 ] ) ) . toEqual ( [ "builtin:ask_user" ] ) ;
31753180 } ) ;
31763181
31773182 it ( "forwards the full bridged set when the run is unrestricted (no toolsAllow)" , async ( ) => {
@@ -3197,7 +3202,6 @@ describe("runCopilotAttempt", () => {
31973202 "edit" ,
31983203 "exec" ,
31993204 "message" ,
3200- "ask_user" ,
32013205 "builtin:ask_user" ,
32023206 ] ) ;
32033207 } ) ;
@@ -3224,7 +3228,7 @@ describe("runCopilotAttempt", () => {
32243228
32253229 const resumeCall = sdk . resumeSession . mock . calls [ 0 ] as unknown [ ] | undefined ;
32263230 const resumeCfg = resumeCall ?. [ 1 ] as { availableTools ?: string [ ] } ;
3227- expect ( resumeCfg ?. availableTools ) . toEqual ( [ "read" , "ask_user" , " builtin:ask_user"] ) ;
3231+ expect ( resumeCfg ?. availableTools ) . toEqual ( [ "read" , "builtin:ask_user" ] ) ;
32283232 } ) ;
32293233
32303234 it ( "forwards `[]` to resumeSession when the bridge returns no tools" , async ( ) => {
@@ -3243,7 +3247,7 @@ describe("runCopilotAttempt", () => {
32433247
32443248 const resumeCall = sdk . resumeSession . mock . calls [ 0 ] as unknown [ ] | undefined ;
32453249 const resumeCfg = resumeCall ?. [ 1 ] as { availableTools ?: string [ ] } ;
3246- expect ( resumeCfg ?. availableTools ) . toEqual ( [ "ask_user" , " builtin:ask_user"] ) ;
3250+ expect ( resumeCfg ?. availableTools ) . toEqual ( [ "builtin:ask_user" ] ) ;
32473251 } ) ;
32483252 } ) ;
32493253
0 commit comments