From f9dd246fd1c742f66c03bc82c26ed74cf8557ac4 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi <17528887+harshithmullapudi@users.noreply.github.com> Date: Thu, 12 Nov 2026 19:07:42 +0000 Subject: [PATCH 1/4] fix(chat-runtime): keep the picked model and effort when a plan approval clears the context claude-agent-acp answers "Yes, clear context and ..." on ExitPlanMode by starting a fresh Claude context. Its restartParams drops model and effort, so the fresh context runs on the agent default and pushes a config_option_update with model "default". The adapter mirrored that, the picker showed Default (recommended), and the desktop pane recorded it, so later recoveries also started on Default. The adapter now notes the model and effort when such an option is chosen and sets them again when the next config_option_update in that turn reports something else. --- .../src/harness/acp/acpAdapter.test.ts | 64 +++++++++++++++++++ .../src/harness/acp/acpAdapter.ts | 43 +++++++++++-- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts index 0e96eeb6e60..f85b184ff12 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts @@ -5970,6 +5970,70 @@ describe("AcpAdapter config options", () => { await adapter.dispose(); }); + + const approvePlan = async (optionId: string) => { + const agent = new FakeAcpAgent(); + agent.protocolVersion = 1; + agent.newSessionConfigOptions = [MODEL_OPTION, EFFORT_OPTION]; + agent.holdPrompts = true; + const { adapter, events } = startAdapter(agent, undefined, { + modelId: "sonnet", + effortId: "low", + }); + await flush(); + adapter.prompt([{ type: "text", text: "plan it" }]); + await flush(); + agent.requestPermissionWith( + { + toolCall: { toolCallId: "tc-plan", title: "Ready to code?" }, + options: [ + { + optionId: "exit-plan-clear-auto", + name: "Yes, clear context (12% used) and use auto mode", + kind: "allow_always", + }, + { + optionId: "exit-plan-auto", + name: "Yes, and use auto mode", + kind: "allow_always", + }, + { optionId: "plan", name: "No, keep planning", kind: "reject_once" }, + ], + }, + 9401, + ); + await flush(); + const approval = itemsOf(events).find( + (item) => item.kind === "approval_request", + ); + const before = agent.sent.length; + adapter.respondToApproval(approval?.id ?? "", { + type: "option", + optionId, + }); + agent.notify("sess-1", { + sessionUpdate: "config_option_update", + configOptions: [MODEL_OPTION, EFFORT_OPTION], + }); + await flush(); + const configured = agent.sent + .slice(before) + .filter((f) => f.method === "session/set_config_option") + .map((f) => f.params); + await adapter.dispose(); + return configured; + }; + + it("puts the model and effort back after a plan approval clears the context", async () => { + expect(await approvePlan("exit-plan-clear-auto")).toEqual([ + { sessionId: "sess-1", configId: "model", value: "sonnet" }, + { sessionId: "sess-1", configId: "effort", value: "low" }, + ]); + }); + + it("leaves the model alone when a plan approval keeps the context", async () => { + expect(await approvePlan("exit-plan-auto")).toEqual([]); + }); }); describe("AcpAdapter attachments", () => { diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.ts index a4336275641..b580bb47db5 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.ts @@ -203,6 +203,8 @@ export type AcpImageStoreContext = { const STARTUP_TIMEOUT_MS = 120_000; const START_OPTIONS_GRACE_MS = 1_000; +// claude-agent-acp starts a fresh context for these plan approvals, on its default model and effort. +const CONTEXT_RESET_OPTION = /^exit-plan-clear-/; const REQUEST_TIMEOUT_MS = 30_000; const STDERR_TAIL_CHARS = 4000; const ASK_MODE_ID = "default"; @@ -467,6 +469,7 @@ export class AcpAdapter implements HarnessAdapter { }, ); private configOptions: SessionConfigOption[] = []; + private picksBeforeContextReset: ChatSelections | null = null; private replaying = false; private agentName: string | null = null; private quietReplay = false; @@ -624,10 +627,11 @@ export class AcpAdapter implements HarnessAdapter { return; } this.pendingApprovals.delete(approvalId); - this.client.respond( - pending.requestId, - this.approvalOutcome(pending, decision), - ); + const outcome = this.approvalOutcome(pending, decision); + if (CONTEXT_RESET_OPTION.test(selectedOptionId(outcome) ?? "")) { + this.picksBeforeContextReset = this.modelAndEffort(); + } + this.client.respond(pending.requestId, outcome); if (this.currentTurn?.status !== "running") this.sendCustomAnswer(); this.emitItem( { @@ -1218,6 +1222,7 @@ export class AcpAdapter implements HarnessAdapter { usage?: AcpPromptUsage, ): void { this.endCompactions(); + this.picksBeforeContextReset = null; this.main.flush(); this.emitTurn({ id: turnId, @@ -1397,6 +1402,7 @@ export class AcpAdapter implements HarnessAdapter { return; case "config_option_update": this.handleConfigOptions(outer.data.update); + this.restorePicksAfterContextReset(); return; case "state_update": this.handleStateUpdate(outer.data.update); @@ -1991,6 +1997,29 @@ export class AcpAdapter implements HarnessAdapter { } } + private modelAndEffort(): ChatSelections { + const current = (category: SelectionCategory) => + this.configOptions.find( + (option) => selectionCategoryOf(option) === category, + )?.currentValue; + const modelId = current("model"); + const effortId = current("thought_level"); + return { + ...(modelId ? { modelId } : {}), + ...(effortId ? { effortId } : {}), + }; + } + + private restorePicksAfterContextReset(): void { + const picks = this.picksBeforeContextReset; + if (!picks) return; + const now = this.modelAndEffort(); + if (now.modelId === picks.modelId && now.effortId === picks.effortId) + return; + this.picksBeforeContextReset = null; + void this.applyConfigSelections(picks); + } + private startModeId( startOptions: HarnessStartOptions, resumed: boolean, @@ -2837,6 +2866,12 @@ function listedSessions(response: unknown): DiscoverSessionsResult { }; } +function selectedOptionId(outcome: unknown): string | undefined { + const optionId = (outcome as { outcome?: { optionId?: unknown } }).outcome + ?.optionId; + return typeof optionId === "string" ? optionId : undefined; +} + function flattenSelectOptions( entries: AcpConfigSelectOption[], labelOf: (name: string) => string, From cf0992f9925e463a283f88bc5898eacc82146f36 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi <17528887+harshithmullapudi@users.noreply.github.com> Date: Thu, 12 Nov 2026 19:15:41 +0000 Subject: [PATCH 2/4] fix(chat-runtime): drop the saved picks on a failed turn or a new pick; correct the root cause The clear-context restart does pass the picked model and pinned effort to the SDK, so the fresh context runs on them. claude-agent-acp's getAvailableModels ignores options.model and reports "default", and the pane saved that. Review: clear the snapshot in failTurn and when the user sets the model or effort, and test a plain accept and a pick made after the reset. --- .../src/harness/acp/acpAdapter.test.ts | 100 +++++++++++++----- .../src/harness/acp/acpAdapter.ts | 7 +- 2 files changed, 78 insertions(+), 29 deletions(-) diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts index f85b184ff12..b9de100b2e5 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, jest, spyOn } from "bun:test"; import { spawn } from "node:child_process"; import type { ChatSelections } from "@superset/chat/core"; -import type { Item } from "@superset/chat/protocol"; +import type { Decision, Item } from "@superset/chat/protocol"; import { AGENT_DEFAULT_MODE, wrapHiddenText } from "@superset/chat/protocol"; import type { AdapterEvent, ResolveAttachment } from "../types"; import { @@ -5971,7 +5971,24 @@ describe("AcpAdapter config options", () => { await adapter.dispose(); }); - const approvePlan = async (optionId: string) => { + const PLAN_OPTIONS = [ + { + optionId: "exit-plan-clear-auto", + name: "Yes, clear context (12% used) and use auto mode", + kind: "allow_always", + }, + { + optionId: "exit-plan-auto", + name: "Yes, and use auto mode", + kind: "allow_always", + }, + { optionId: "plan", name: "No, keep planning", kind: "reject_once" }, + ]; + + const approvePlan = async ( + decision: Decision, + reported: { model: string; effort: string }, + ) => { const agent = new FakeAcpAgent(); agent.protocolVersion = 1; agent.newSessionConfigOptions = [MODEL_OPTION, EFFORT_OPTION]; @@ -5986,19 +6003,7 @@ describe("AcpAdapter config options", () => { agent.requestPermissionWith( { toolCall: { toolCallId: "tc-plan", title: "Ready to code?" }, - options: [ - { - optionId: "exit-plan-clear-auto", - name: "Yes, clear context (12% used) and use auto mode", - kind: "allow_always", - }, - { - optionId: "exit-plan-auto", - name: "Yes, and use auto mode", - kind: "allow_always", - }, - { optionId: "plan", name: "No, keep planning", kind: "reject_once" }, - ], + options: PLAN_OPTIONS, }, 9401, ); @@ -6007,32 +6012,71 @@ describe("AcpAdapter config options", () => { (item) => item.kind === "approval_request", ); const before = agent.sent.length; - adapter.respondToApproval(approval?.id ?? "", { - type: "option", - optionId, - }); + adapter.respondToApproval(approval?.id ?? "", decision); agent.notify("sess-1", { sessionUpdate: "config_option_update", - configOptions: [MODEL_OPTION, EFFORT_OPTION], + configOptions: [ + { ...MODEL_OPTION, currentValue: reported.model }, + { ...EFFORT_OPTION, currentValue: reported.effort }, + ], }); await flush(); - const configured = agent.sent - .slice(before) - .filter((f) => f.method === "session/set_config_option") - .map((f) => f.params); - await adapter.dispose(); - return configured; + const configured = () => + agent.sent + .slice(before) + .filter((f) => f.method === "session/set_config_option") + .map((f) => f.params); + return { adapter, agent, configured }; }; it("puts the model and effort back after a plan approval clears the context", async () => { - expect(await approvePlan("exit-plan-clear-auto")).toEqual([ + const { adapter, configured } = await approvePlan( + { type: "option", optionId: "exit-plan-clear-auto" }, + { model: "opus", effort: "high" }, + ); + expect(configured()).toEqual([ { sessionId: "sess-1", configId: "model", value: "sonnet" }, { sessionId: "sess-1", configId: "effort", value: "low" }, ]); + await adapter.dispose(); + }); + + it("treats a plain accept of a plan as the clear-context option it selects", async () => { + const { adapter, configured } = await approvePlan( + { type: "accept" }, + { model: "opus", effort: "high" }, + ); + expect(configured()).toEqual([ + { sessionId: "sess-1", configId: "model", value: "sonnet" }, + { sessionId: "sess-1", configId: "effort", value: "low" }, + ]); + await adapter.dispose(); }); it("leaves the model alone when a plan approval keeps the context", async () => { - expect(await approvePlan("exit-plan-auto")).toEqual([]); + const { adapter, configured } = await approvePlan( + { type: "option", optionId: "exit-plan-auto" }, + { model: "opus", effort: "high" }, + ); + expect(configured()).toEqual([]); + await adapter.dispose(); + }); + + it("keeps a model the user picks after the context reset", async () => { + const { adapter, agent, configured } = await approvePlan( + { type: "option", optionId: "exit-plan-clear-auto" }, + { model: "sonnet", effort: "low" }, + ); + adapter.setConfigOption("model", "opus"); + agent.notify("sess-1", { + sessionUpdate: "config_option_update", + configOptions: [MODEL_OPTION, EFFORT_OPTION], + }); + await flush(); + expect(configured()).toEqual([ + { sessionId: "sess-1", configId: "model", value: "opus" }, + ]); + await adapter.dispose(); }); }); diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.ts index b580bb47db5..3d6f4a0075e 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.ts @@ -203,7 +203,7 @@ export type AcpImageStoreContext = { const STARTUP_TIMEOUT_MS = 120_000; const START_OPTIONS_GRACE_MS = 1_000; -// claude-agent-acp starts a fresh context for these plan approvals, on its default model and effort. +// claude-agent-acp reports model "default" for the fresh context these plan approvals start, whatever it runs. const CONTEXT_RESET_OPTION = /^exit-plan-clear-/; const REQUEST_TIMEOUT_MS = 30_000; const STDERR_TAIL_CHARS = 4000; @@ -712,6 +712,10 @@ export class AcpAdapter implements HarnessAdapter { const sessionId = this.sessionId; if (!client || !sessionId) return Promise.resolve(false); const previous = this.configOptions; + const changed = previous.find((option) => option.id === configId); + const category = changed && selectionCategoryOf(changed); + if (category === "model" || category === "thought_level") + this.picksBeforeContextReset = null; const previousModeId = configId === this.modeConfigId ? this.modeId : undefined; this.configOptions = previous.map((option) => @@ -1251,6 +1255,7 @@ export class AcpAdapter implements HarnessAdapter { private failTurn(turnId: string, error: TurnError): void { this.endCompactions(); this.customAnswer = null; + this.picksBeforeContextReset = null; this.main.flush(); this.cancelPendingApprovals(turnId); this.emitTurn({ From b7ae76c5d824789db4f8008bce263f58342fa752 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi <17528887+harshithmullapudi@users.noreply.github.com> Date: Tue, 17 Nov 2026 06:12:55 +0000 Subject: [PATCH 3/4] test(chat-runtime): saved picks do not outlive a finished or failed turn The clearing in finishTurn and failTurn had no test. Each case fails when its clearing line is removed. --- .../src/harness/acp/acpAdapter.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts index b9de100b2e5..fd7e134d052 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts @@ -6078,6 +6078,27 @@ describe("AcpAdapter config options", () => { ]); await adapter.dispose(); }); + + it.each([ + ["finishes", (agent: FakeAcpAgent) => agent.releasePrompts("end_turn")], + ["fails", (agent: FakeAcpAgent) => agent.failHeldPrompts(-32603, "boom")], + ])("does not carry the saved picks past a turn that %s", async (_, end) => { + const { adapter, agent, configured } = await approvePlan( + { type: "option", optionId: "exit-plan-clear-auto" }, + { model: "sonnet", effort: "low" }, + ); + end(agent); + await flush(); + adapter.prompt([{ type: "text", text: "next" }]); + await flush(); + agent.notify("sess-1", { + sessionUpdate: "config_option_update", + configOptions: [MODEL_OPTION, EFFORT_OPTION], + }); + await flush(); + expect(configured()).toEqual([]); + await adapter.dispose(); + }); }); describe("AcpAdapter attachments", () => { From f2cd816d6fcf9c9a5bd420d0524e5d3be949bd91 Mon Sep 17 00:00:00 2001 From: Harshith Mullapudi <17528887+harshithmullapudi@users.noreply.github.com> Date: Wed, 18 Nov 2026 08:13:40 +0000 Subject: [PATCH 4/4] fix(chat-runtime): let only the reset's own report restore the picks The restore fired on any config_option_update that differed from the snapshot, until the turn ended. When the reset's report already matched (a pick of Default, the common case), the snapshot stayed armed for the whole implementation turn, and a model_refusal_fallback later in that turn was switched back. claude-agent-acp answers a clear-context option with a deny and no config change, so the first config_option_update after the approval is the fresh context's. The snapshot is now used up by that update: restored if it differs, dropped if not. It also covers a reset that reports the settings model rather than "default". A model or effort the user picks during the restart now updates the snapshot instead of dropping it, so the reset's report does not override that pick. Checked against claude-agent-acp 0.107.0 with the v1 protocol that acpCatalogue pins. --- .../src/harness/acp/acpAdapter.test.ts | 112 +++++++++++------- .../src/harness/acp/acpAdapter.ts | 15 +-- 2 files changed, 74 insertions(+), 53 deletions(-) diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts index fd7e134d052..06073b16a97 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts @@ -5985,18 +5985,23 @@ describe("AcpAdapter config options", () => { { optionId: "plan", name: "No, keep planning", kind: "reject_once" }, ]; + const PLAN_MODEL_OPTION = { + ...MODEL_OPTION, + options: [ + { value: "default", name: "Default (recommended)" }, + ...MODEL_OPTION.options, + ], + }; + const approvePlan = async ( decision: Decision, - reported: { model: string; effort: string }, + picked: ChatSelections = { modelId: "sonnet", effortId: "low" }, ) => { const agent = new FakeAcpAgent(); agent.protocolVersion = 1; - agent.newSessionConfigOptions = [MODEL_OPTION, EFFORT_OPTION]; + agent.newSessionConfigOptions = [PLAN_MODEL_OPTION, EFFORT_OPTION]; agent.holdPrompts = true; - const { adapter, events } = startAdapter(agent, undefined, { - modelId: "sonnet", - effortId: "low", - }); + const { adapter, events } = startAdapter(agent, undefined, picked); await flush(); adapter.prompt([{ type: "text", text: "plan it" }]); await flush(); @@ -6013,27 +6018,33 @@ describe("AcpAdapter config options", () => { ); const before = agent.sent.length; adapter.respondToApproval(approval?.id ?? "", decision); - agent.notify("sess-1", { - sessionUpdate: "config_option_update", - configOptions: [ - { ...MODEL_OPTION, currentValue: reported.model }, - { ...EFFORT_OPTION, currentValue: reported.effort }, - ], - }); - await flush(); + const report = async (model: string, effort: string) => { + agent.notify("sess-1", { + sessionUpdate: "config_option_update", + configOptions: [ + { ...PLAN_MODEL_OPTION, currentValue: model }, + { ...EFFORT_OPTION, currentValue: effort }, + ], + }); + await flush(); + }; const configured = () => agent.sent .slice(before) .filter((f) => f.method === "session/set_config_option") .map((f) => f.params); - return { adapter, agent, configured }; + return { adapter, agent, configured, report }; }; - it("puts the model and effort back after a plan approval clears the context", async () => { - const { adapter, configured } = await approvePlan( - { type: "option", optionId: "exit-plan-clear-auto" }, - { model: "opus", effort: "high" }, - ); + it.each([ + ["Default", "default"], + ["the settings model", "opus"], + ])("puts the model and effort back when the cleared context reports %s", async (_, reported) => { + const { adapter, configured, report } = await approvePlan({ + type: "option", + optionId: "exit-plan-clear-auto", + }); + await report(reported, "high"); expect(configured()).toEqual([ { sessionId: "sess-1", configId: "model", value: "sonnet" }, { sessionId: "sess-1", configId: "effort", value: "low" }, @@ -6042,10 +6053,10 @@ describe("AcpAdapter config options", () => { }); it("treats a plain accept of a plan as the clear-context option it selects", async () => { - const { adapter, configured } = await approvePlan( - { type: "accept" }, - { model: "opus", effort: "high" }, - ); + const { adapter, configured, report } = await approvePlan({ + type: "accept", + }); + await report("default", "high"); expect(configured()).toEqual([ { sessionId: "sess-1", configId: "model", value: "sonnet" }, { sessionId: "sess-1", configId: "effort", value: "low" }, @@ -6054,48 +6065,57 @@ describe("AcpAdapter config options", () => { }); it("leaves the model alone when a plan approval keeps the context", async () => { - const { adapter, configured } = await approvePlan( - { type: "option", optionId: "exit-plan-auto" }, - { model: "opus", effort: "high" }, - ); + const { adapter, configured, report } = await approvePlan({ + type: "option", + optionId: "exit-plan-auto", + }); + await report("default", "high"); expect(configured()).toEqual([]); await adapter.dispose(); }); - it("keeps a model the user picks after the context reset", async () => { - const { adapter, agent, configured } = await approvePlan( - { type: "option", optionId: "exit-plan-clear-auto" }, - { model: "sonnet", effort: "low" }, - ); - adapter.setConfigOption("model", "opus"); - agent.notify("sess-1", { - sessionUpdate: "config_option_update", - configOptions: [MODEL_OPTION, EFFORT_OPTION], + it("puts back the model the user picks while the context resets", async () => { + const { adapter, configured, report } = await approvePlan({ + type: "option", + optionId: "exit-plan-clear-auto", }); + adapter.setConfigOption("model", "opus"); await flush(); + await report("default", "low"); expect(configured()).toEqual([ { sessionId: "sess-1", configId: "model", value: "opus" }, + { sessionId: "sess-1", configId: "model", value: "opus" }, ]); await adapter.dispose(); }); + it.each([ + ["Default", "default"], + ["a model the reset reports truly", "sonnet"], + ])("does not undo a later model fallback after a reset that kept %s", async (_, modelId) => { + const { adapter, configured, report } = await approvePlan( + { type: "option", optionId: "exit-plan-clear-auto" }, + { modelId, effortId: "low" }, + ); + await report(modelId, "low"); + await report("opus", "low"); + expect(configured()).toEqual([]); + await adapter.dispose(); + }); + it.each([ ["finishes", (agent: FakeAcpAgent) => agent.releasePrompts("end_turn")], ["fails", (agent: FakeAcpAgent) => agent.failHeldPrompts(-32603, "boom")], ])("does not carry the saved picks past a turn that %s", async (_, end) => { - const { adapter, agent, configured } = await approvePlan( - { type: "option", optionId: "exit-plan-clear-auto" }, - { model: "sonnet", effort: "low" }, - ); + const { adapter, agent, configured, report } = await approvePlan({ + type: "option", + optionId: "exit-plan-clear-auto", + }); end(agent); await flush(); adapter.prompt([{ type: "text", text: "next" }]); await flush(); - agent.notify("sess-1", { - sessionUpdate: "config_option_update", - configOptions: [MODEL_OPTION, EFFORT_OPTION], - }); - await flush(); + await report("default", "high"); expect(configured()).toEqual([]); await adapter.dispose(); }); diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.ts index 3d6f4a0075e..eb959e53f23 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.ts @@ -203,7 +203,7 @@ export type AcpImageStoreContext = { const STARTUP_TIMEOUT_MS = 120_000; const START_OPTIONS_GRACE_MS = 1_000; -// claude-agent-acp reports model "default" for the fresh context these plan approvals start, whatever it runs. +// claude-agent-acp reports the default or settings model for the fresh context these plan approvals start, whatever it runs. const CONTEXT_RESET_OPTION = /^exit-plan-clear-/; const REQUEST_TIMEOUT_MS = 30_000; const STDERR_TAIL_CHARS = 4000; @@ -714,8 +714,10 @@ export class AcpAdapter implements HarnessAdapter { const previous = this.configOptions; const changed = previous.find((option) => option.id === configId); const category = changed && selectionCategoryOf(changed); - if (category === "model" || category === "thought_level") - this.picksBeforeContextReset = null; + if (this.picksBeforeContextReset && category === "model") + this.picksBeforeContextReset.modelId = value; + if (this.picksBeforeContextReset && category === "thought_level") + this.picksBeforeContextReset.effortId = value; const previousModeId = configId === this.modeConfigId ? this.modeId : undefined; this.configOptions = previous.map((option) => @@ -2018,11 +2020,10 @@ export class AcpAdapter implements HarnessAdapter { private restorePicksAfterContextReset(): void { const picks = this.picksBeforeContextReset; if (!picks) return; - const now = this.modelAndEffort(); - if (now.modelId === picks.modelId && now.effortId === picks.effortId) - return; this.picksBeforeContextReset = null; - void this.applyConfigSelections(picks); + const now = this.modelAndEffort(); + if (now.modelId !== picks.modelId || now.effortId !== picks.effortId) + void this.applyConfigSelections(picks); } private startModeId(