@@ -381,7 +381,9 @@ const makeInstructionCompactionHarness = Effect.fnUntraced(function* (
381381 messageText : string ,
382382 expectedStatus = "completed" ,
383383 reopen = false ,
384+ interactionMode : "default" | "plan" = "default" ,
384385 ) {
386+ const turnRuntimePolicy = { ...runtimePolicy , interactionMode } ;
385387 if ( reopen ) {
386388 const nativeSessionId = providerThread . nativeThreadRef ?. nativeId ;
387389 if ( nativeSessionId == null ) return yield * Effect . die ( "Expected a persisted native session" ) ;
@@ -390,7 +392,7 @@ const makeInstructionCompactionHarness = Effect.fnUntraced(function* (
390392 providerThread = yield * session . runtime . resumeThread ( {
391393 providerThread,
392394 modelSelection,
393- runtimePolicy,
395+ runtimePolicy : turnRuntimePolicy ,
394396 } ) ;
395397 }
396398 const { runtime } = session ;
@@ -399,7 +401,7 @@ const makeInstructionCompactionHarness = Effect.fnUntraced(function* (
399401 threadId,
400402 providerThread,
401403 instanceId,
402- runtimePolicy,
404+ runtimePolicy : turnRuntimePolicy ,
403405 now,
404406 ordinal : ++ ordinal ,
405407 messageText,
@@ -1047,6 +1049,25 @@ describe("AcpAdapterV2", () => {
10471049 } ) . pipe ( Effect . provide ( layerTest ) , Effect . scoped ) ,
10481050 ) ;
10491051
1052+ it . live . each ( [ false , true ] ) (
1053+ "invalidates old instructions after a failed mode change (reopen: %s)" ,
1054+ ( reopen ) =>
1055+ Effect . gen ( function * ( ) {
1056+ const runTurn = yield * makeInstructionCompactionHarness ( {
1057+ T3_ACP_FAIL_PROMPT_ORDINAL : "2" ,
1058+ } ) ;
1059+ assert . include (
1060+ ( yield * runTurn ( "Plan first." , "completed" , false , "plan" ) ) [ 0 ] ?. text ?? "" ,
1061+ "T3 Code interaction mode: Plan" ,
1062+ ) ;
1063+ yield * runTurn ( "Implement now." , "failed" ) ;
1064+ assert . include (
1065+ ( yield * runTurn ( "Plan again." , "completed" , reopen , "plan" ) ) [ 0 ] ?. text ?? "" ,
1066+ "T3 Code interaction mode: Plan" ,
1067+ ) ;
1068+ } ) . pipe ( Effect . provide ( layerTest ) , Effect . scoped ) ,
1069+ ) ;
1070+
10501071 it . live ( "records instructions before ACP work-state completion ends the run" , ( ) =>
10511072 Effect . gen ( function * ( ) {
10521073 const runTurn = yield * makeInstructionCompactionHarness (
0 commit comments