feat(session): persisting agent for session#1842
Closed
spoons-and-mirrors wants to merge 5 commits into
Closed
Conversation
Contributor
Author
|
very light conflict with #1854 |
github-actions
Bot
force-pushed
the
dev
branch
from
August 12, 2025 17:36
9aa0700 to
5141fe8
Compare
Member
|
each message keeps track of the last agent that was used - can we use that instead to load the right agent when switching to a session? |
Contributor
Author
|
Will look into it in a few 👌 |
Contributor
Author
|
closing the PR, wrong way to go at it indeed |
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 free
to 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.
Summary
This PR implements per-session agent persistence, ensuring that the selected agent is remembered for each individual session and resolves issue #1812
Before
Previously, agent selection was a global setting. When a user switched agents in one session, that agent would remain active even when switching to other sessions. This meant that switching between sessions did not restore the agent that was last used in that specific context.
After
With this change, each session now stores its own agent. The behavior is as follows:
This creates a more intuitive and seamless user experience, as the agent context is now tied directly to the session it's being used in.
Key Changes
Backend:
Infoschema inpackages/opencode/src/session/index.tswas extended with an optionalagentfield.PATCH /session/:idendpoint was added topackages/opencode/src/server/server.tsto handle session updates.POST /sessionendpoint now accepts anagentparameter on creation.packages/opencode/src/storage/storage.tsto update existing session data.Go SDK:
Sessionstruct inpackages/sdk/go/session.gowas updated to include theAgentfield.Session.Update()method was added to call the newPATCHendpoint.Session.New()method was updated to accept an agent on creation.TUI:
SessionSelectedMsgandAgentSelectedMsghandlers inpackages/tui/internal/tui/tui.gowere updated to restore and persist the agent for the current session.cycleModefunction inpackages/tui/internal/app/app.gonow makes a backend call to update the session when the agent is switched.