Imported from PyModel/pythinker-cli (
src/pythinker_code/acp/AGENTS.md). Install upstream withnpx skills add PyModel/pythinker-cli --skill acp. Copyright stays with the author.
ACP Integration Notes (pythinker-code)
Protocol summary (ACP overview)
- ACP is JSON-RPC 2.0 with request/response methods plus one-way notifications.
- Typical flow:
initialize-> optionalauthenticate->session/neworsession/load->session/promptwithsession/updatenotifications and optionalsession/cancel. - Clients provide
session/request_permissionand optional terminal/filesystem methods. - All ACP file paths must be absolute; line numbers are 1-based.
Entry points and server modes
- Deprecated single-session server:
PythinkerCLI.run_acp()usesACP->ACPServerSingleSession.- Code:
src/pythinker_code/app.py,src/pythinker_code/ui/acp/__init__.py. - Used when running CLI with
--acpUI mode; every ACP method now raises a deprecation error.
- Code:
- Multi-session server:
acp_main()runsACPServerwithuse_unstable_protocol=True.- Code:
src/pythinker_code/acp/__init__.py,src/pythinker_code/acp/server.py. - Exposed via the
pythinker acpcommand insrc/pythinker_code/cli/__init__.py.
- Code:
Capabilities advertised
prompt_capabilities:embedded_context=True,image=True,audio=False.mcp_capabilities:http=True,sse=False.- Multi-session:
load_session=True,session_capabilities.listandsession_capabilities.resumesupported. auth_methodsadvertises terminal auth forpythinker login.
Session lifecycle (implemented behavior)
session/new- Multi-session: creates a persisted
Session, buildsPythinkerCLI, storesACPSession. - Sends
AvailableCommandsUpdatefor slash commands on session creation. - MCP servers passed by ACP are converted via
acp_mcp_servers_to_mcp_config.
- Multi-session: creates a persisted
session/load- Multi-session only: loads by
Session.find, then buildsPythinkerCLIandACPSession. - No history replay yet (TODO).
- Multi-session only: loads by
session/list- Multi-session only: lists sessions via
Session.list, no pagination.
- Multi-session only: lists sessions via
session/resume- Multi-session only: loads the session if needed and returns current mode/model state.
session/set_mode- Multi-session only: accepts only
default.
- Multi-session only: accepts only
session/set_model- Multi-session only: switches the session LLM and persists default model/thinking settings.
session/prompt- Uses
ACPSession.prompt()to stream updates and produce astop_reason. - Stop reasons:
end_turn,max_turn_requests,cancelled.
- Uses
session/cancel- Sets the per-turn cancel event to stop the prompt.
Streaming updates and content mapping
- Text chunks ->
AgentMessageChunk. - Think chunks ->
AgentThoughtChunk. - Tool calls:
- Start ->
ToolCallStartwith JSON args as text content. - Streaming args ->
ToolCallProgresswith updated title/args. - Results ->
ToolCallProgresswithcompletedorfailed. - Tool call IDs are prefixed with turn ID to avoid collisions across turns.
- Start ->
- Plan updates:
TodoDisplayBlockis converted intoAgentPlanUpdate.
- Available commands:
AvailableCommandsUpdateis sent right after session creation.
Prompt/content conversion
- Incoming prompt blocks:
- Supported:
TextContentBlock,ImageContentBlock(converted to data URL). - Unsupported types are logged and ignored.
- Supported:
- Tool result display blocks:
DiffDisplayBlock->FileEditToolCallContent.HideOutputDisplayBlocksuppresses tool output in ACP (used by terminal tool).
Tool integration and permission flow
- ACP sessions use
ACPHostto route filesystem reads/writes through ACP clients. - If the client advertises
terminalcapability, theShelltool is replaced by an ACP-backedTerminaltool.- Uses ACP
terminal/create, waits for exit, streamsTerminalToolCallContent, then releases the terminal handle.
- Uses ACP
- Approval requests in the core tool system are bridged to ACP
session/request_permissionwith allow-once/allow-always/reject options.
Current gaps / not implemented
fork_sessionis not implemented.ext_method/ext_notificationfor custom ACP extensions are stubbed.- Deprecated single-session
--acprejects all methods and exists only to report migration guidance. session/loadstill has no history replay.
Filesystem (ACP client-backed)
- When the client advertises
fs.readTextFile/fs.writeTextFile,ACPHostroutes reads and writes through ACPfs/*methods. ReadFileusesHostPath.read_lines, whichACPHostimplements via ACP reads.ReadMediaFileusesHostPath.read_bytesto load image/video payloads through ACP reads.WriteFileusesHostPath.read_text/write_text/append_textand still generates diffs and approvals in the tool layer.
Zed-specific notes (as of current integration)
- Terminal auth advertises
pythinker login;authenticateverifies that login completed. - External agent clients should use
pythinker acp, not deprecatedpythinker --acp.