Uh oh!
There was an error while loading. Please reload this page.
fix: keep manually selected model across turns - #39322
Open
tbartik wants to merge 1 commit into
Open
Conversation
Contributor
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
A selected model was overwritten by the agent's configured model after every turn, so staying on a non-default model was impossible. TUI: Prompt restored the model from the last user message on session hydration. Drop that, and instead seed the model from durable session state only when the agent has no local override. App: the agent Select calls agents.select even when the value is unchanged, and agent.set always rewrote the model as `item.model ?? prev?.model`. Skip re-applying the already-persisted agent so an explicit pick survives. Switching agents still applies that agent's model. Closesanomalyco#39319
tbartikforce-pushed
the
keep-model-selection
branch
from
July 28, 2026 11:43
0bc21f2 to
f901b9cCompare6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes#39319
Type of change
What does this PR do?
If your agent has a model configured, picking a different model in the picker doesn't stick. The prompt runs on your pick, then it snaps back to the agent's model for the next turn.
Two separate causes, one per UI:
TUI —
Promptrestored the model from the last user message whenever a session hydrated, which overwrote the pick. I removed that. The model is now seeded from durable session state incontext/local.tsx, but only when the agent has no local override, so reopening a session still restores its model.App/desktop — the agent
Selectcallsagents.select(value)even when the value hasn't changed, andagent.setalways rewrote state withmodel: item.model ?? prev?.model. Because the agent has a configured model,item.modelis always set and always won. Now re-applying the already-persisted agent is skipped.The guard compares against persisted state rather than
agent.current()on purpose:store.currentis initialised to the first agent in the list, so comparing against the resolved current agent would make the first genuineagent.seta no-op and never persist anything.Switching agents still applies that agent's configured model — only redundant re-application is skipped.
How did you verify your code works?
Built a local binary (
script/build.ts --single) and ran the desktop app (bun run --cwd packages/desktop dev), with abuildagent pinned to one model:Also added unit tests for both guards, and
bun testpasses inpackages/tui(193) andpackages/app(548), with typecheck clean in both.Screenshots / recordings
The change is behavioural, not visual: the model label in the composer stops reverting between turns.
Checklist