You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(app): scope manual model override to the selected agent - #40604
Nothing clears it on an agent switch, and openNewTab seeds a new draft with the previous tab's model — so the stale value is already in place before the agent is ever consulted.
Instead of reordering that list, this tags the persisted selection with the agent it was made under and only honours it while that agent is active. PromptModel gains an optional agent field; override() returns the persisted model only when the tag matches. Untagged values (pre-existing drafts, models inherited from another tab) lose to a configured agent model, but are still used for agents that have no model configured — so the openNewTab inheritance stays intact where it is unambiguous. set and variant.set write the tag, and variant.selected reads through override so a stale variant can't leak across a switch.
Result: new sessions and agent switches land on the agent's model, while a deliberate pick sticks for as long as you stay on that agent.
The field is optional and the undefined case is handled explicitly, so no migration is needed.
Note on the neighbouring PRs: #38372 fixes this from the agent select callback, which a new tab never fires. #39319 is the same code path from the other side, where the agent model overwriting a manual pick is the bug — scoping rather than reordering is what lets both hold at once. Happy to rework this if you would rather land one of those first.
How did you verify your code works?
Applied the equivalent transformation to the shipped 1.18.13 renderer bundle and ran the desktop app against agents with different configured models. Checked: new session, agent switch, manual pick surviving across turns on the same agent, switching away and back, and variant selection. Not yet exercised as a source build.
Screenshots / recordings
No visual change — the model picker shows a different value. Happy to add a recording if useful.
Note: The PR description explicitly acknowledges these neighboring PRs (#38372 and #39319) as alternative approaches to the same issue, with this PR (#40604) taking a different approach by scoping the persisted selection with an agent field rather than reordering. The author notes that the scoping approach allows both concerns to be addressed simultaneously.
These are closely related but complementary solutions rather than duplicates of the current PR.
Supporting feedback — Web UI (opencode serve), v1.18.18
This is exactly the semantics we need. Self-hosted Web UI with two primary agents bound to different-capability models:
plan → local multimodal model (vLLM, vision)
build → cloud text model (DeepSeek V4 Flash via OpenCode Go)
Scoping the persisted draft model to the agent it was chosen under (PromptModel.agent tag) matches the desired behaviour: a deliberate pick sticks while that agent is active and is restored on switch-back, while untouched agents still resolve to their configured model. The openNewTab inheritance remaining intact where unambiguous is also the right call.
One behavioural question for the Web flow, since this PR targets the app composer: does the same scoping apply when the model is switched through the composer dropdown in the Web UI (the persisted model-selection local-storage state in local.tsx, which currently writes a single State.model with no agent tag)? Happy to verify once this lands in a release.
Thank you for the detailed write-up — the optional-field/no-migration approach is clean.
Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.
This PR was closed because it matched the following cleanup criteria:
The PR was created more than 1 month ago
The PR had fewer than 2 positive reactions
Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR
PRs created within the last month are not affected by this cleanup.
If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.
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
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 #38333
Type of change
What does this PR do?
In the v2 composer the persisted draft model is checked before the agent's configured model:
Nothing clears it on an agent switch, and
openNewTabseeds a new draft with the previous tab's model — so the stale value is already in place before the agent is ever consulted.Instead of reordering that list, this tags the persisted selection with the agent it was made under and only honours it while that agent is active.
PromptModelgains an optionalagentfield;override()returns the persisted model only when the tag matches. Untagged values (pre-existing drafts, models inherited from another tab) lose to a configured agent model, but are still used for agents that have no model configured — so theopenNewTabinheritance stays intact where it is unambiguous.setandvariant.setwrite the tag, andvariant.selectedreads throughoverrideso a stale variant can't leak across a switch.Result: new sessions and agent switches land on the agent's model, while a deliberate pick sticks for as long as you stay on that agent.
The field is optional and the undefined case is handled explicitly, so no migration is needed.
Note on the neighbouring PRs: #38372 fixes this from the agent select callback, which a new tab never fires. #39319 is the same code path from the other side, where the agent model overwriting a manual pick is the bug — scoping rather than reordering is what lets both hold at once. Happy to rework this if you would rather land one of those first.
How did you verify your code works?
Applied the equivalent transformation to the shipped 1.18.13 renderer bundle and ran the desktop app against agents with different configured models. Checked: new session, agent switch, manual pick surviving across turns on the same agent, switching away and back, and variant selection. Not yet exercised as a source build.
Screenshots / recordings
No visual change — the model picker shows a different value. Happy to add a recording if useful.
Checklist