fix(app): persist per-agent model selections across agent switches#23420
fix(app): persist per-agent model selections across agent switches#23420kagura-agent wants to merge 1 commit intoanomalyco:devfrom
Conversation
When switching agents, the outgoing agent's model/variant is now saved to a per-agent map in the session state. Switching back restores the previously selected model instead of reverting to the agent's configured default. The agents map is also preserved through snapshot/promote/restore flows, so model selections survive session resume (opencode -c). Fixes anomalyco#23369
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: Related PR:
However, PR #18013 appears to be addressing variant state scoping specifically, while the current PR focuses on persisting model selections across agent switches during session resume. They're complementary but address different aspects of agent state management. No exact duplicate PRs found addressing the same issue (#23369) regarding model persistence across agent switches on session resume. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Closing — this has a merge conflict and the branch is no longer available for rebase. The underlying issue (#23369) may have been addressed in other changes. Happy to submit a fresh PR if the issue persists. |
Issue for this PR
Closes #23369
Type of change
What does this PR do?
The session model state in
local.tsxstores a single{ agent, model, variant }object per session. When switching agents, the incoming agent's configured model overwrites the previous selection. On session resume (opencode -c), only the last active agent's model is restored — others revert to config defaults.This adds a per-agent model map (
agents) to the session state. When switching agents, the outgoing agent's model is saved to the map before loading the target agent's saved selection. The map is carried through snapshot/promote/restore flows so selections survive session resume.The
agentsfield is optional — existing persisted state without it works via??fallbacks (no migration needed).How did you verify your code works?
agent.set()saves outgoing → restores incoming,write()preservesagentsvia spread,snapshot()/promote()carry the mapagentsis optional, old state shape still worksScreenshots / recordings
N/A — logic change, no UI changes.
Checklist