Skip to content

Keep ACP-native model state in sync with the agent - #5053

Merged
ymichael merged 1 commit into
get-bb:mainfrom
timurkhakhalev:codex/fix-acp-live-model-selection
Oct 8, 2026
Merged

ymichael merged 1 commit into
get-bb:mainfrom
timurkhakhalev:codex/fix-acp-live-model-selection

Conversation

@timurkhakhalev

@timurkhakhalev timurkhakhalev commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

#5141 fixed #5051 by applying a changed model, effort, or tier before each follow-up prompt. It decides whether to call a setter by comparing the request with AcpThreadSession.nativeConfig, its snapshot of the agent's current selection. That snapshot could go stale in three ways, and then bb skipped a switch it needed to make:

  1. Setters that answer without state. The ACP spec's session/set_model response is an empty object. Hermes Agent returns {}. The snapshot then stayed on the agent's startup model, so switching back to that model was skipped and the turn ran on the previous one.
  2. The agent switching its own model. reconcileExecutionSettings compared the request only with the previous request, so a config_option_update that moved the agent off the requested model was never corrected.
  3. Partial failure. When a model change succeeded and a later effort or tier setter threw, the acknowledged model change was dropped from the snapshot.

What changed

All changes are in packages/provider-bridge-acp/src/bridge/bridge.ts. The PR was rebased onto #5141 and keeps its design. It no longer carries this PR's original parallel implementation.

  • selectAcpNativeModel, selectAcpNativeReasoning, and selectAcpNativeServiceTier write each acknowledged setting to session.nativeConfig as it lands. When the response carries no state, they record the requested value.
  • reconcileExecutionSettings also re-applies the selection when the snapshot's model differs from the requested one (acpNativeModelDrifted).
  • The effort and tier setters accept a null result like the model setters.

No wire, CLI, or SDK surface changes.

How you verified

  • Added tests in src/bridge/bridge.test.ts: A → B → A with empty setter results (config option and models state), an agent self-switch, a tier failure after an acknowledged model change, and a queued steer that changes the model. The first four fail on main and pass with the fix. The steer test passes on both and stays as a regression guard. fake-acp-agent.mjs gains FAKE_ACP_EMPTY_MODEL_RESULT and a self-switch-model prompt.
  • pnpm exec turbo run typecheck lint test --filter=@bb/provider-bridge-acp: passed (385 tests, 4 skipped).
  • Real agents on a pnpm start:worktree instance, with a wrapper logging ACP traffic and each agent's own records as ground truth:
    • Hermes Agent, starting on its default gpt-6.1-sol, then gpt-6-luna, then back to gpt-6.1-sol. With main's bridge, bb sent no set_model on the third turn and Hermes's session ended on gpt-6-luna. With this branch, bb sent the switch and the session ended on gpt-6.1-sol.
    • opencode, Haiku (low) → GPT-6 Luna → Haiku (low) → Haiku (high) → Haiku (high). opencode's database recorded the requested model and variant on every reply, and the unchanged last turn sent no setters.
  • Not exercised on real agents: the self-switch and partial-failure cases. No local agent self-switches, and Cursor, which the partial-failure test mirrors, was not signed in.

Fixes #5051

🤖 Generated with Claude Code

AGENT GENERATED

get-bb#5141 applies changed model, effort, and tier on follow-up turns, but its
snapshot of the agent's current selection could go stale in three ways:

- Setters answering without state (session/set_model's spec response is
  an empty object, which Hermes Agent sends) left the snapshot on the
  agent's startup model, so switching back to that model was skipped and
  the turn ran on the previous one.
- A model the agent switched itself was never re-asserted, because the
  bridge compared the request only with the previous request.
- A model acknowledged before a later effort or tier setter failed was
  dropped from the snapshot.

Selectors now record each acknowledged setting on the session as it lands,
fall back to the requested value when the response carries no state, and
reconciliation re-applies the selection when the snapshot's model differs
from the requested one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the codex/fix-acp-live-model-selection branch from f1e00d8 to 6a1144c Compare October 8, 2026 04:19
@ymichael ymichael changed the title Fix ACP model selection on follow-up turns Keep ACP-native model state in sync with the agent Oct 8, 2026
@ymichael
ymichael merged commit 2eba81b into get-bb:main Oct 8, 2026
84 of 85 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP follow-up turns ignore changed model selection and keep the startup model

2 participants