Skip to content

Conversation

@AObuchow
Copy link

@AObuchow AObuchow commented Dec 9, 2025

This PR was made in anticipation of session/resume. Since session/resume is not yet officially part of the ACP spec, I implemented session/load to illustrate the approach that could be taken. Related to #64 and agentclientprotocol/agent-client-protocol#279 (comment)

The key idea is that Claude Code has an undocumented feature: you can pass extraArgs: {"session-id": <UUID>} to the options when sending the initial prompt, and Claude Code will use that UUID as the session ID. This lets us map the ACP session ID to the Claude Code session ID.

I'm not a fan of relying on undocumented behaviour: Anthropic could break this implementation. However, I've been sitting on this idea for a while and haven't seen it mentioned yet in any ACP discussions, so I figured it was worth bringing up :)

If this approach is something that would be worth adding to claude-code-acp, I'd be happy to clean up this PR further and get it merge ready.

Side note: I've been working on my own ACP client since September that I'm excited to eventually unveil, and hope to help contribute to the ACP ecosystem :) Zed Industries & the ACP community are doing an amazing job at bringing the standardization that is needed in the agents space - thank you for all your great work.

@cla-bot
Copy link

cla-bot bot commented Dec 9, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @AObuchow on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@AObuchow
Copy link
Author

AObuchow commented Dec 9, 2025

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Dec 9, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @AObuchow on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot
Copy link

cla-bot bot commented Dec 9, 2025

The cla-bot has been summoned, and re-checked this pull request!

@AObuchow
Copy link
Author

AObuchow commented Dec 9, 2025

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Dec 9, 2025

The cla-bot has been summoned, and re-checked this pull request!

@cla-bot cla-bot bot added the cla-signed label Dec 9, 2025
@AObuchow AObuchow marked this pull request as ready for review December 9, 2025 01:07
@AObuchow AObuchow marked this pull request as draft December 9, 2025 01:07
This adds support for the ACP session/load protocol, enabling clients to
reconnect to existing sessions after disconnection.

Key changes:
- Add loadSession capability declaration in initialize()
- Pass session ID to SDK via extraArgs["session-id"] in newSession() to
  synchronize ACP and SDK session IDs for persistence
- Implement loadSession() method that uses SDK's resume option to load
  the existing conversation history

Note: extraArgs["session-id"] is not part of the public SDK API and may
break in future versions. The loadSession capability should migrate to
session/resume once it's added to the ACP schema.

Signed-off-by: Andrew Obuchowicz <[email protected]>
Tests that a session can be resumed after process restart:
- Creates a session and establishes context with a stored code
- Kills the subprocess to simulate disconnection
- Starts a new subprocess and calls loadSession with the original session ID
- Verifies the context is preserved by asking about the stored code

Includes proper subprocess cleanup using killAndWait to ensure
processes fully exit before test completion.

Signed-off-by: Andrew Obuchowicz <[email protected]>
@AObuchow AObuchow force-pushed the acp-session-load-poc branch from 063cfda to 59c4c10 Compare December 9, 2025 01:20
@AObuchow
Copy link
Author

AObuchow commented Dec 9, 2025

I had missed the recent #193 so I rebased my changes off of that and added 01ff678 (#196). I forgot about the differences in the ACP UUID format vs Claude Code UUID format, so I'm glad that's already addressed from that PR 😁

@benbrandt it seems like you were about to naturally arrive that the same solution proposed by this PR?

The extraArgs with session-id was already set earlier in the options
object (added in commit 3f44543). This duplicate was a merge artifact.
Moved the explanatory comment to the correct location.

Signed-off-by: Andrew Obuchowicz <[email protected]>
@AObuchow AObuchow force-pushed the acp-session-load-poc branch from 59c4c10 to 01ff678 Compare December 9, 2025 01:33
@gsabran
Copy link
Contributor

gsabran commented Dec 10, 2025

FYI I've supported resuming in my client by passing the session id through _meta.claudeCode.options.resume in the initialization request. It gets forwarded to Claude Code here.

@benbrandt
Copy link
Member

@AObuchow we are working with the unstable flags, starting with fork, on #183

That one has a more unified way to set the settings for a session, and I think we will expand resume from that one.

Thanks for doing this, but I think I will close this one for now to avoid everyone dealing with lots of merge conflicts and we can revisit once fork lands. thanks!

@benbrandt benbrandt closed this Dec 11, 2025
@AObuchow
Copy link
Author

@benbrandt that makes sense to me - thank you for taking a look into this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants