Skip to content

fix(app): persist per-agent model selections across agent switches#23420

Closed
kagura-agent wants to merge 1 commit intoanomalyco:devfrom
kagura-agent:fix/persist-per-agent-model
Closed

fix(app): persist per-agent model selections across agent switches#23420
kagura-agent wants to merge 1 commit intoanomalyco:devfrom
kagura-agent:fix/persist-per-agent-model

Conversation

@kagura-agent
Copy link
Copy Markdown

@kagura-agent kagura-agent commented Apr 19, 2026

Issue for this PR

Closes #23369

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The session model state in local.tsx stores 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 agents field is optional — existing persisted state without it works via ?? fallbacks (no migration needed).

How did you verify your code works?

  1. Reviewed the data flow: agent.set() saves outgoing → restores incoming, write() preserves agents via spread, snapshot()/promote() carry the map
  2. Verified backward compatibility: agents is optional, old state shape still works
  3. CI passes (check, check-standards, check-compliance, check-duplicates)

Screenshots / recordings

N/A — logic change, no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@kagura-agent
Copy link
Copy Markdown
Author

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.

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.

Only current selected agent's model persists when resuming a session (other agent(s) revert to default)

1 participant