Sessions archive rfd - #2161
Draft
Rizzen wants to merge 2 commits into
Draft
Sessions archive rfd#2161Rizzen wants to merge 2 commits into
Rizzen wants to merge 2 commits into
Conversation
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.
title: "Session Archive and Unarchive"
Authors: Mark Tkachenko (@Rizzen), Evgeniy Stepanov(@xtmq)
Elevator pitch
Standardize reversible session archiving: Clients can hide conversations from default history, discover archived sessions, and restore them with the same ID and saved history.
Status quo
session/deleteremoves sessions from history but permits permanent deletion.session/closereleases execution resources. Neither guarantees reversible hiding, andsession/listcannot explicitly request archived sessions.What we propose to do about it
Methods
session/archivehides a session from default history:{ "jsonrpc": "2.0", "id": 1, "method": "session/archive", "params": { "sessionId": "sess_abc123" } }session/unarchiverestores it:{ "jsonrpc": "2.0", "id": 2, "method": "session/unarchive", "params": { "sessionId": "sess_abc123" } }Both return an empty result with the matching request ID:
{ "jsonrpc": "2.0", "id": 1, "result": {} }sessionIdis required and non-null. Both methods support the usual optional_metafield in requests and responses.Capabilities
Agents advertise the methods independently:
agentCapabilities.sessionCapabilities.archiveand.unarchive.capabilities.session.archiveand.unarchive.{}enables the corresponding method; omission ornullmeans unsupported. Clients MUST check support before calling it.Advertising either capability MUST also enable archived listing and state reporting. In v1, this requires
sessionCapabilities.list: {}; v2 already requires listing for Agents supporting sessions.Example v1 initialization response:
{ "jsonrpc": "2.0", "id": 0, "result": { "protocolVersion": 1, "agentCapabilities": { "sessionCapabilities": { "list": {}, "archive": {}, "unarchive": {} } } } }Listing and state
Extend
session/listwith an optionalarchivedparameter to include archived sessions:null, orfalsetrueClients MUST NOT send this parameter without either archive capability. It combines with
cwdand applies before pagination. Clients keep the samecwdandarchivedvalues when followingnextCursor; changing either starts a new pagination sequence.Include archived sessions alongside unarchived sessions:
{ "jsonrpc": "2.0", "id": 3, "method": "session/list", "params": { "cwd": "/home/user/project", "archived": true } }{ "jsonrpc": "2.0", "id": 3, "result": { "sessions": [ { "sessionId": "sess_abc123", "cwd": "/home/user/project", "title": "Implement session archive support", "archived": true }, { "sessionId": "sess_def456", "cwd": "/home/user/project", "title": "Update session documentation", "archived": false } ] } }Add an optional, non-null boolean
archivedto:SessionInfo: required in list results when either archive capability is advertised. Otherwise, omission conveys no archive-state guarantee.SessionInfoUpdate: omission leaves state unchanged. Agents SHOULD report changes through existingsession_info_updatenotifications to connected session observers. Listing remains the source of truth after reconnecting; no global subscription is introduced.{ "jsonrpc": "2.0", "method": "session/update", "params": { "sessionId": "sess_abc123", "update": { "sessionUpdate": "session_info_update", "archived": true } } }Guarantees
Resource not found(-32002). Neither method requires activation on the current connection.archivedparameter. Unarchive does not undo deletion; Clients must not substitute deletion for archiving.updatedAt.Shiny future
A user archives a conversation in one Client, finds it in another Client's archived history, and restores it for continued work.
Implementation details and plan
Add the methods, capabilities, filter, and state fields behind
unstable_session_archive; regenerate v1/v2 schemas and update conversions, SDKs, and docs. Validate restoration, retries, persistence, pagination, active sessions, and deletion compatibility with Agent and Client implementations before preview.Frequently asked questions
Why separate methods?
They match the requested actions and allow independent capabilities. A boolean setter is possible, but a general metadata-editing API exceeds this request. Extending deletion cannot guarantee recovery when Agents may permanently remove data.
What needs discussion?
Revision history