Skip to content

fix(model): prevent conversation model override snap-back after /model#1229

Open
sarahwooders wants to merge 1 commit intomainfrom
sarah/fix-conversation-model-override-revert
Open

fix(model): prevent conversation model override snap-back after /model#1229
sarahwooders wants to merge 1 commit intomainfrom
sarah/fix-conversation-model-override-revert

Conversation

@sarahwooders
Copy link
Contributor

@sarahwooders sarahwooders commented Mar 2, 2026

Summary

Fixes a conversation-scoped model regression where selecting a model with /model could revert back to the agent default after subsequent async state syncs.

What changed

  • Add a sync-generation guard in src/cli/App.tsx so stale async model-sync runs can't overwrite newer state.
  • Track recent per-conversation model override writes and skip local fallback-to-agent-default during a short freshness window.
  • Mark override freshness on both /model selection and reasoning-tier flush paths.
  • Add best-effort fallback in src/agent/modify.ts to conversations.retrieve after conversations.update if the update response omits model.
  • Add a wiring regression test for the new guard behavior and update existing model wiring assertions.

Why

handleModelSelect correctly persists conversation overrides, but later sync passes (triggered by agent refresh / conversation sync) could run with stale timing and call applyAgentModelLocally, resetting UI state back to the agent model.

Testing

  • bun test src/tests/agent/model-preset-refresh.wiring.test.ts
  • bun test src/tests/cli/reasoning-cycle-wiring.test.ts
  • bun test src/tests/cli/conversation-model-sync-guard.wiring.test.ts

Notes

There is an existing unrelated typecheck issue in App.tsx around compact params (compaction_settings.model), pre-existing in this branch base and not introduced by this PR.

@jnjpng
Copy link
Contributor

jnjpng commented Mar 5, 2026

#1238 might be a superset of this, gonna have discussion on that one if the race condition is legit on /model

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.

2 participants