Skip to content

feat(acp): session/resume, set_mode, set_config_option - #86

Merged
rohitg00 merged 1 commit into
mainfrom
feat/acp-additional-methods
May 6, 2026
Merged

feat(acp): session/resume, set_mode, set_config_option#86
rohitg00 merged 1 commit into
mainfrom
feat/acp-additional-methods

Conversation

@rohitg00

@rohitg00 rohitg00 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

PR #63 shipped 8 client→agent methods. ACP defines three more that fell to METHOD_NOT_FOUND until now. This PR implements all of them and updates the method table to be exhaustive so the deferred surface is fully visible.

Methods added

Method Behaviour
session/resume Like session/load but skips history replay. Refreshes cwd + mcpServers on the session record, claims ownership so subsequent agent::events route here. Per ACP: "useful for agents that can resume sessions but don't implement full session loading."
session/set_mode Persists modeId on the session record. Brain workers can read it on the next prompt turn (system-prompt suffix, per-mode tool gating, etc.). Catalog validation is the brain's concern.
session/set_config_option Persists configId / value pairs in config_options on the session record. Same split: persistence here, semantics in the brain.

Implementation notes

  • SessionRecord gains:
    • mode: Option<String> (skip_serializing_if = "Option::is_none" — backward-compatible with pre-existing records)
    • config_options: serde_json::Map<String, Value> (default empty)
  • New update_session_record helper does a read-modify-write of one record under the per-session history mutex that already serializes append_history. No parallel lock map.
  • agentCapabilities.sessionCapabilities now advertises { list: {}, close: {}, resume: {} } — matches the ACP schema slots in this version. set_mode / set_config_option ship without an explicit capability flag because the in-repo schema doesn't include those slots yet; clients that try them succeed, clients that don't try are unaffected.

README

Method table is now exhaustive. The misleading "deferred to v0.2" line is replaced with explicit rows for every method:

  • Implemented: initialize, authenticate, session/{new,load,resume,list,prompt,cancel,close,set_mode,set_config_option}, session/update
  • Deferred (reverse-RPC, agents use iii primitives directly): session/request_permission, fs/{read,write}_text_file, terminal/{create,kill,output,release,wait_for_exit}

Validation

  • 17 lib + 10 protocol envelope tests pass (3 new round-trip tests for the new param shapes)
  • cargo clippy --all-targets -- -D warnings clean
  • Live smoke against the 7-worker brain stack:
    • sessionCapabilities advertises {close, list, resume} on initialize
    • session/set_mode persists modeId="code" (verified via state::get)
    • session/set_config_option persists configId="thinking" value "high"
    • session/resume refreshes cwd to "/new"
    • All three return {} on success, INVALID_PARAMS (-32602) on missing sessionId
    • Full canonical brain flow (real Claude streaming through agent::events) still passes

Test plan

  • cargo test — 17 lib + 10 protocol envelope tests pass
  • cargo clippy --all-targets -- -D warnings clean
  • Live smoke covering all 3 new methods + missing-session error path
  • Canonical brain flow regression smoke (session/prompt streaming)
  • Post-merge: trigger acp release if version bumped in a follow-up

Follow-ups

Reverse-RPC paths remain deferred — they need a JSON-RPC framer that can originate requests from the agent side. Internal iii brains today use iii primitives directly for filesystem and terminal access. Lands as a separate PR when an external ACP agent (consumed via future acp-client) needs the editor to act on its behalf.

Summary by CodeRabbit

  • New Features

    • Added session resumption capability with environment state preservation and history handling
    • Introduced per-session configuration management and mode settings
    • Extended ACP session lifecycle operations and capabilities
  • Documentation

    • Expanded ACP session management documentation with new operation details and capability information

PR #63 shipped 8 client->agent methods. ACP spec defines three more
client->agent methods that fall to METHOD_NOT_FOUND today; this commit
implements all of them.

session/resume — like session/load but skips history replay. Per ACP
spec: 'useful for agents that can resume sessions but don't implement
full session loading.' Refreshes cwd + mcpServers on the session record
and claims ownership so subsequent agent::events route to this
subprocess.

session/set_mode — persists modeId on the session record. Brain
workers can read it on the next session/prompt turn (e.g. via a system
prompt suffix or per-mode tool gating). Validation of the mode against
any agent-specific catalog is left to the brain.

session/set_config_option — persists configId/value pairs in
config_options on the session record. Same rationale as set_mode:
persistence here, semantics in the brain.

Implementation notes:

- SessionRecord gains mode: Option<String> (skip_serializing_if =
  is_none) and config_options: serde_json::Map<String, Value>
  (defaults empty). Backward-compatible with sessions written before
  this change since both fields use serde defaults.
- update_session_record helper: read-modify-write of one record
  guarded by the per-session history mutex (we reuse the lock that
  already exists for append_history rather than adding a parallel
  lock map for the same key).
- agentCapabilities.sessionCapabilities now advertises { list: {},
  close: {}, resume: {} } — matches the ACP schema slots that exist
  in this version. set_mode and set_config_option ship without an
  explicit capability flag because the in-repo schema doesn't have
  those slots yet; clients that try them succeed, clients that don't
  try are unaffected.

README method table is now exhaustive: every ACP method is listed
with its current implementation status. The previously-misleading
'session/request_permission deferred to v0.2' line is replaced with
explicit per-method rows for fs/* and terminal/* so the deferred
surface is fully visible.

Reverse-RPC paths (session/request_permission, fs/*, terminal/*)
remain deferred — they need a JSON-RPC framer that can originate
requests from the agent side, and our internal iii brains use iii
primitives directly for filesystem and terminal access. Those can
land later without breaking this PR.

Validation:

- 17 lib tests + 10 protocol envelope tests pass (3 new round-trip
  tests for the new param shapes).
- cargo clippy --all-targets -- -D warnings clean.
- Live smoke against the 7-worker brain stack:
  - sessionCapabilities advertises {close, list, resume} on
    initialize.
  - session/set_mode persists modeId='code' (verified via state::get).
  - session/set_config_option persists configId='thinking' value='high'.
  - session/resume refreshes cwd to '/new'.
  - All three return {} on success, INVALID_PARAMS (-32602) on
    missing sessionId.
  - Full canonical brain flow (session/prompt streaming real Claude
    through agent::events) still passes.
@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

This PR extends the ACP session management with three new capabilities: session resume (restoring environment state without history replay), session mode configuration, and per-session configuration options. Supporting types, handler methods, session record fields, and tests are added across the codebase.

Changes

ACP Session Lifecycle Extension

Layer / File(s) Summary
Data Shape & Types
acp/src/types.rs, acp/src/session.rs
Three new parameter structs added (SessionResumeParams, SessionSetModeParams, SessionSetConfigOptionParams). SessionRecord extended with mode (optional string) and config_options (map) fields.
Core Session Management
acp/src/handler.rs
Three new handler methods implemented: session_resume (updates cwd and mcp_servers without history replay), session_set_mode (stores mode_id on session), and session_set_config_option (stores config key-value pairs). Initialize response extended with sessionCapabilities: [list, close, resume].
Documentation
acp/README.md
Methods table expanded with entries for session/resume, session/set_mode, session/set_config_option, session/list, session/cancel, session/close, and session/update. Narrative added on capability advertising, deferred permissions, and brain contract negotiation.
Tests
acp/tests/protocol.rs
Three JSON round-trip tests validate deserialization of the new parameter types and assert key field presence (session_id, cwd, mcp_servers; mode_id; config_id and value).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • iii-hq/workers#63: Extends the same ACP session management codebase with session/resume and configuration APIs.

Poem

🐰 A rabbit hops through sessions new,
Resume and modes now in the queue!
Config options, safely stored,
Session state is now restored.
Hopping forward, smooth and clean—
Best ACP flow we've ever seen! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(acp): session/resume, set_mode, set_config_option' directly and concisely summarizes the three main methods added in the PR, which is the primary focus of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/acp-additional-methods

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rohitg00
rohitg00 merged commit cecd1a4 into main May 6, 2026
7 checks passed
@rohitg00
rohitg00 deleted the feat/acp-additional-methods branch May 6, 2026 18:43
rohitg00 added a commit that referenced this pull request May 6, 2026
PR #86 implemented session/resume, session/set_mode, and
session/set_config_option, but the README header still said reverse-RPC
paths are 'deferred to v0.2'. That line conflated the three new
client->agent methods (now done) with the reverse-RPC surface (still
deferred), and v0.2 isn't accurate framing for the latter either since
those methods only land when external ACP agents (future acp-client)
need them.

Replaces the line with an explicit per-method enumeration in the status
block, splitting client->agent (all eleven implemented) from reverse-RPC
(deferred). Points at the Methods table for full status.
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