Introduces experimental session list/load/resume#289
Merged
Conversation
Example usage:
;; Subscribe to all events
(agent-shell-subscribe-to
:shell-buffer shell-buffer
:on-event (lambda (event)
(message \"event: %s\" (map-elt event :event))))
;; Subscribe to file writes
(agent-shell-subscribe-to
:shell-buffer shell-buffer
:event \\='file-write
:on-event (lambda (event)
(let ((data (map-elt event :data)))
(message \"wrote: %s\" (map-elt data :path)))))
;; Unsubscribe
(let ((token (agent-shell-subscribe-to
:shell-buffer shell-buffer
:on-event #\\='my-handler)))
(agent-shell-unsubscribe :subscription token))"
(unless on-event
(error "Missing required argument: :on-event"))
(unless shell-buffer
(error "Missing required argument: :shell-buffer"))
(let ((token (cl-incf agent-shell--subscription-counter)))
(with-current-buffer shell-buffer
(let ((subscriptions (map-elt (agent-shell--state) :event-subscriptions)))
(map-put! (agent-shell--state)
:event-subscriptions
(cons (list (cons :token token)
(cons :event event)
(cons :on-event on-event))
subscriptions))))
token))
…l into pr263-resume-session
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.
Introduces experimental session listing/loading/resuming. These features are not yet stable in ACP and may break if protocol changes.
This work is a collaboration between @farra @travisjeffery and myself.
For the feature to work, agents are required to implement:
And either one of these:
I've validated the flows against two agents known to implement the required ACP at the following versions:
Claude Code (resume)
@anthropic-ai/claude-code: 2.1.34@zed-industries/claude-code-acp: 0.16.1Codex (load)
Other agents
No other agents have been tested at this time. Please try against other agents and report issues, but please verify the above ACP features are implemented by those agents.
To enable the experimental
list/resumeflow use:Also introduced
agent-shell-prefer-session-resume(defaults to t). In instances where both loading and resuming are available, it prefers resuming as its way more lightweight (no need to replay and render the entire history).To prefer loading, disable resuming with:
You can start a new shell as usual. For example
M-x agent-shellorM-x agent-shell-anthropic-start-claude-codeorM-x agent-shell-openai-start-codex.Note: If you don't get offered any sessions, it's possible the agents haven't been run on the latest versions and haven't had a chance to save a session.
Resuming gives you a list of sessions to choose from via
completing-read. If you have a completion framework, it may look different, but mine looks as follows (using ivy):