@@ -2415,94 +2415,6 @@ describe("AcpAdapterV2", () => {
24152415 } ) . pipe ( Effect . provide ( layerTest ) , Effect . scoped ) ,
24162416 ) ;
24172417
2418- // regression: #27646 an agent leaving its native mode on its own must not keep the next turn there
2419- it . live ( "reapplies the selected native mode after the agent switches mode itself" , ( ) =>
2420- Effect . gen ( function * ( ) {
2421- const childProcessSpawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
2422- const path = yield * Path . Path ;
2423- const mockAgentPath = yield * path . fromFileUrl (
2424- new URL ( "../../../scripts/acp-mock-agent.ts" , import . meta. url ) ,
2425- ) ;
2426- const protocolEvents = yield * Queue . unbounded < EffectAcpProtocol . AcpProtocolLogEvent > ( ) ;
2427- const instanceId = ProviderInstanceId . make ( "acp-test-agent-mode-drift" ) ;
2428- const threadId = ThreadId . make ( "thread-acp-agent-mode-drift" ) ;
2429- const adapter = yield * makeAcpAdapterV2 ( {
2430- instanceId,
2431- flavor : {
2432- driver : ACP_TEST_DRIVER ,
2433- capabilities : AcpProviderCapabilitiesV2 ,
2434- makeRuntime : makeMockRuntime ( {
2435- childProcessSpawner,
2436- mockAgentPath,
2437- protocolEvents,
2438- environment : { T3_ACP_SELF_SWITCH_MODE_ON_FIRST_PROMPT : "ask" } ,
2439- } ) ,
2440- } ,
2441- selfInvocation : yield * resolveSelfInvocation ( ) ,
2442- } ) ;
2443- const runtimePolicy = ProviderAdapter . ProviderAdapterV2RuntimePolicy . make ( {
2444- runtimeMode : "full-access" ,
2445- interactionMode : "default" ,
2446- cwd : process . cwd ( ) ,
2447- } ) ;
2448- const modelSelection = {
2449- instanceId,
2450- model : "default" ,
2451- options : [ { id : "mode" , value : "architect" } ] ,
2452- } as const ;
2453- const runtime = yield * adapter . openSession ( {
2454- threadId,
2455- providerSessionId : ProviderSessionId . make ( "provider-session-acp-agent-mode-drift" ) ,
2456- modelSelection,
2457- runtimePolicy,
2458- } ) ;
2459- const providerThread = yield * runtime . ensureThread ( {
2460- threadId,
2461- modelSelection,
2462- runtimePolicy,
2463- } ) ;
2464- const now = yield * DateTime . now ;
2465- const runTurn = Effect . fnUntraced ( function * ( ordinal : number ) {
2466- yield * runtime . startTurn (
2467- makeTurnInput ( {
2468- threadId,
2469- providerThread,
2470- instanceId,
2471- runtimePolicy,
2472- now,
2473- ordinal,
2474- modelSelection,
2475- } ) ,
2476- ) ;
2477- yield * runtime . events . pipe (
2478- Stream . takeUntil ( ( event ) => event . type === "turn.terminal" ) ,
2479- Stream . runDrain ,
2480- ) ;
2481- const modeSetsBeforePrompt : Array < unknown > = [ ] ;
2482- while ( true ) {
2483- const event = yield * Queue . take ( protocolEvents ) ;
2484- if ( event . direction !== "outgoing" ) continue ;
2485- const method = rawProtocolMethod ( event ) ;
2486- if ( method === "session/prompt" ) return modeSetsBeforePrompt ;
2487- if (
2488- method === "session/set_config_option" &&
2489- rawProtocolRequestParam ( event , "configId" ) === "mode"
2490- ) {
2491- modeSetsBeforePrompt . push ( rawProtocolRequestParam ( event , "value" ) ) ;
2492- }
2493- }
2494- } ) ;
2495-
2496- assert . deepEqual ( yield * runTurn ( 1 ) , [ "architect" ] ) ;
2497- assert . deepEqual (
2498- yield * runTurn ( 2 ) ,
2499- [ "architect" ] ,
2500- "the agent left architect mode during turn 1, so turn 2 must set it back before prompting" ,
2501- ) ;
2502- assert . deepEqual ( yield * runTurn ( 3 ) , [ ] , "an unchanged mode is not re-sent" ) ;
2503- } ) . pipe ( Effect . provide ( layerTest ) , Effect . scoped ) ,
2504- ) ;
2505-
25062418 // regression: #27646 an ACP v1 agent can report a mode switch without a config option update
25072419 it . live ( "reapplies the selected native mode after a mode-only update from a v1 agent" , ( ) =>
25082420 Effect . gen ( function * ( ) {
@@ -2589,6 +2501,7 @@ describe("AcpAdapterV2", () => {
25892501 ...prompt ( [ { sessionUpdate : "current_mode_update" , currentModeId : "ask" } ] ) ,
25902502 ...setArchitect ,
25912503 ...prompt ( [ ] ) ,
2504+ ...prompt ( [ ] ) ,
25922505 ] ,
25932506 } ,
25942507 ACP_TEST_DRIVER ,
@@ -2634,7 +2547,8 @@ describe("AcpAdapterV2", () => {
26342547 runtimePolicy,
26352548 } ) ;
26362549 const now = yield * DateTime . now ;
2637- for ( const ordinal of [ 1 , 2 ] ) {
2550+ // Turn 2 must set architect back before prompting; turn 3 must not re-send it.
2551+ for ( const ordinal of [ 1 , 2 , 3 ] ) {
26382552 yield * runtime . startTurn (
26392553 makeTurnInput ( {
26402554 threadId,
0 commit comments