PR #9682 review: keep model/effort on plan clear-context

PR #9682 · Review workspace · author harshithmullapudi · reviewed at f9dd246f · 2026-11-12

Summary

After a plan approval with "Yes, clear context", claude-agent-acp starts a fresh Claude context and publishes a config_option_update that shows the model as default. The desktop pane then saves chatModelId: "default", so later recoveries and restarts really run on Default. This PR makes AcpAdapter note the model and effort when an exit-plan-clear-* option is chosen. On the first config update in that turn that shows a different model or effort, it sets them again with applyConfigSelections. The note is cleared when it is used or when the turn ends.

Verdict

minor issues The fix is small, correctly scoped to one turn, and tested. It works on the real 0.85.0 sequence. But the root cause in the description and in the code comment is not what 0.85.0 does, and that changes the stated follow-up and where the real fix belongs.

Findings

Medium · accuracy / approach

The agent keeps the model. It only reports Default.

packages/chat-runtime/src/harness/acp/acpAdapter.ts:206 says the fresh context runs "on its default model and effort". The PR body says restartParams "explicitly deletes model and effort". In 0.85.0, dist/clear-context-coordinator.js:2-27 deletes the original options and then adds back model: session.models.currentModelId (unless it is default) and effort: session.effortPinnedLevel. Effort picked through set_config_option is pinned (acp-agent.js:6239), so it survives. The model goes to the SDK query through ...userProvidedOptions (acp-agent.js:6632). But getAvailableModels (dist/session-model.js) never reads options.model. It falls back to models[0], which is default. So the fresh context runs the picked model but reports Default. The real damage is that the pane saves that report and later sessions actually run Default.

Fix: Change the comment to say that claude-agent-acp reports Default after these restarts, and that the pane saves that report. Correct the description too. The "first API call can still run on Default" limitation is most likely not real in 0.85.0, so drop it or confirm it. Report the bug upstream: getAvailableModels should take options.model into account. Once that is fixed upstream, this workaround can be removed, so link the issue next to CONTEXT_RESET_OPTION.

Low · test coverage

The test covers only the direct option path

packages/chat-runtime/src/harness/acp/acpAdapter.test.ts:6010 responds with {type:"option"}. The description gives the generic accept decision (and auto-approve through approvePendingPermissions, acpAdapter.ts:2309) as an equally likely way to hit this. I checked it with a temporary probe and it works. A config update that keeps the same model, arriving before the reset, does not use up the note.

Fix (optional): Make the test helper send { type: "accept" } in one of the two cases. Then the regex match in approvalOutcome is covered too.

Nit

selectedOptionId re-parses an untyped outcome

acpAdapter.ts:2869 casts the unknown returned by approvalOutcome. If approvalOutcome returned a typed union ({outcome:{outcome:"selected",optionId}} | …), the helper and the cast would not be needed. This is not a blocker.

Evidence

Surface: this PR changes only packages/chat-runtime (the ACP adapter used by desktop and host-service chat). There is no UI change, so there are no screenshots. Evidence is test and probe output at f9dd246f.

$ bun test src/harness/acp/acpAdapter.test.ts         # PR head
 187 pass  0 fail
$ bun test   (packages/chat-runtime, whole suite)
 523 tests across 43 files · 0 fail · 2 skip
$ # acpAdapter.ts from base da70e87f, PR tests kept
(fail) AcpAdapter config options > puts the model and effort back after a plan approval clears the context
 1 pass  1 fail     # regression test fails on main, as claimed
$ # temporary probe (not committed): generic accept, same-model update, then reset update
PROBE1 [{"configId":"model","value":"sonnet"},{"configId":"effort","value":"low"}]
PROBE2 []          # turn ends before any reset: nothing sent, note cleared
$ bunx tsc --noEmit -p packages/chat-runtime   → exit 0
$ bunx biome check (2 changed files)            → no fixes

Not run end to end: no Claude login on this box. The only key in the environment is a server API key, and ANTHROPIC_MODEL is set, which changes claude-agent-acp's model priority (getAvailableModels step 1). For both reasons I did not drive a real plan turn through desktop. The agent behavior above comes from reading @agentclientprotocol/claude-agent-acp@0.85.0/dist.

Questions for the author

Test / CI notes

Everything was run at f9dd246fd1c742f66c03bc82c26ed74cf8557ac4. GitHub checks are all green: Lint, Typecheck, Test, Sherif, Build CLI, deploy previews, Vale. CodeRabbit was still pending when this was written, and cubic is neutral. The local commands and output are above. The probe test was added to a scratch copy and reverted, and the working tree is clean.