Skip to content

acp: list, fork and close sessions where the agent advertises them - #170

Merged
morajabi merged 2 commits into
mainfrom
claude/acp-session-ops-34f83d
Nov 23, 2026
Merged

morajabi merged 2 commits into
mainfrom
claude/acp-session-ops-34f83d

Conversation

@morajabi

@morajabi morajabi commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Wire change (provider-facing ACP)

  • Methods sent: session/list, session/fork, session/close.
  • Capability flags read: agentCapabilities.sessionCapabilities.list, .fork, .close, read once from the initialize response.
  • Vendored protocol: no source patch. List and close are stable in agent-client-protocol 2.0.0 / schema 1.5.0. Fork turns on the vendored crate's existing unstable_session_fork cargo feature in crates/agent-driver-acp/Cargo.toml. INLINE-PATCHES.md is unchanged and the 1 MiB frame limit stays.
  • Gating: two layers. The harness checks the flags first: a missing list returns an empty page, a missing fork returns OpenError::Unavailable, and a missing close keeps today's release (Unsubscribed). The driver's list_sessions / fork_session / close_session also fail closed with Unsupported if the method was not advertised. IsolatedAcpHarness (the CLI's ACP route) refuses an unadvertised list or fork before launching any agent process.

Who gets it

  • OpenCode v2.2.5 ACP advertises list, fork, close (plus delete, resume). OpenCode builds that still take the ACP route gain all three. Newer OpenCode builds use the native OpenCode harness.
  • Amp (pinned adapter 0.8.1+e4ccce1.inline3) only advertises loadSession. No change.
  • Claude over ACP (emergency path, durable resume off) also gets list and fork turned off.

Behaviour

  • List: maps session/list onto SessionPage. Unusable session ids and blank titles are dropped, updatedAt (ISO 8601) becomes Unix seconds, and the agent's cursor carries over. The isolated harness lists through its tool-free settings probe (or a short-lived tool-free process) and hides its own probe sessions. Nothing in the v2 CLI calls HarnessDriver::sessions yet (for any harness), so listing is ready for a future v2 browser.
  • Fork: OpenMode::Fork { at: None } sends session/fork. A missing source maps to OpenError::NotFound. ACP has no fork point, so at: Some(..) returns Unavailable: "Fork here" works, and spawn_thread forks (which pass the lead's last finished turn) already fall back to a fresh start from the brief. A fork's first turn re-sends the thread's guide (new thread), unlike resume.
  • Close: release() sends session/close when advertised. On success it returns NativeReleased, cancels that session's pending approvals and questions, and drops it from the settings catalog map. On failure, after a 2 s close timeout, or when not advertised it returns Unsubscribed, as before. A stalled close never ends the connection or holds the chat's worker. In the isolated harness the private process is still stopped afterwards.
  • AcpHarness now holds the concrete AcpDriver instead of dyn AgentDriver (only tests constructed it with a driver).

Salvaged from closed #153, rebuilt from main. Left out: the 64 MiB frame limit, the 1,000-hop default and the other parity items.

Tests

  • New crates/agent-driver-acp/tests/session_ops.rs:
    • Scripted in-process agent: advertised list paging, list error, fork with guide, fork point and missing source, close success, close failure, a close that never answers, and nothing sent when unadvertised.
    • Python-script agents through IsolatedAcpHarness: methods land in the right process, a close that never answers still stops the process within seconds, and nothing is launched or sent when unadvertised.
  • A driver unit test checks the flags are strictly advertisement-driven.
  • cargo test -p inline-agent-driver-acp passes; cargo test -p inline-cli bridge passes (672 passed, 9 ignored).
  • cargo clippy -p inline-agent-driver-acp -p inline-cli --all-targets -D warnings is clean.

Follow-ups

  • A v2 /sessions browser on HarnessDriver::sessions.
  • Mark sessions this bridge has open as held_by in ACP listings.
  • Hide OpenCode settings-probe sessions left over from before a restart (the isolated listing only hides this run's probes).
  • Avoid starting an agent process per listing page when no settings probe is live.
  • Map session/delete to the Archive op, if wanted.

🤖 Generated with Claude Code

read sessionCapabilities.list/fork/close at initialize and send
session/list, session/fork and session/close only when advertised.
the harness maps listings to the session browser page, opens forks at
the end of a session (no fork point in acp), and closes on release so
the agent lets go (native release). the isolated harness refuses
unadvertised list and fork before launching a process and hides its
picker probes from listings. enables the vendored crate's
unstable_session_fork feature; no vendored source change.
@morajabi
morajabi merged commit 899fed8 into main Nov 23, 2026
48 checks passed
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.

1 participant