fix(app): scope manual model override to the selected agent - #40604
fix(app): scope manual model override to the selected agent#40604Dominic-Leidenfrost wants to merge 2 commits into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found related PRs that are addressing similar model selection issues, though they are not exact duplicates: Related PRs:
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 (
|
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