Book as an ACP Agent in Xcode 26.6+
This document explains how to register Book as an Agent Client Protocol (ACP) agent in Xcode 26.6 or later.
For ACP server configuration (transports, _meta keys) see ACP Server Configuration. For MCP tool configuration see MCP Configuration. For the server architecture internals see Embedding Book as an ACP Agent (Phase 4).
Prerequisites
| Requirement | Notes |
|---|---|
Xcode 26.6 or later |
ACP agent support shipped in 26.6 |
Book installed |
|
|
Set in |
Registering Book in Xcode
-
Open Xcode โ Settings โ AI (or use the menu Xcode โ Integrations โ AI Agents).
-
Click Add an ACP Agent (the
+button). -
Fill in the following fields:
| Field | Value |
|---|---|
Name |
|
Command |
|
Arguments |
|
Environment |
(leave empty โ Book reads from |
Tip: You can find the exact path to the
bkbinary by runningwhich bkin Terminal.
-
Click Save. Xcode will launch
bk serveas a subprocess and perform the ACPinitializehandshake automatically.
How It Works
When Xcode launches bk serve, the following protocol sequence occurs:
Xcode bk serve (subprocess)
โโโโโโ โโโโโโโโโโโโโโโโโโโโ
stdin โโโ initialize โโโโโโโถ AgentInfo{capabilities}
stdout โโโ response โโโโโโโโโโ
stdin โโโ session/new โโโโโโโถ AcpAgentSession{sessionId}
stdout โโโ response โโโโโโโโโโ
stdin โโโ session/prompt โโโโถ AgentLoop.run()
stdout โโโ session/update* โโ (streaming text deltas, tool calls, token usage updates)
stdout โโโ PromptResponse โโโ
...
stdin โโโ (close) โโโโโโโโโโโถ bk process exits
All messages are NDJSON (newline-delimited JSON), one JSON-RPC 2.0 object per line. After each prompt turn, bk serve streams session/update notifications containing text deltas, tool calls, and token usage statistics (usage_update, enabled by default; embedding CLIs can set emitUsageUpdates = false in AcpStartConfig to opt out). Logging is written under ~/.bk/agent/logs/ โ stdout is reserved exclusively for ACP messages.
Capabilities Advertised to Xcode
Book advertises the following capabilities during initialize:
| Capability | Value | Meaning |
|---|---|---|
|
|
Xcode can restore a previous Book session |
|
|
Xcode can browse Book’s session history |
|
see below |
Slash commands visible in Xcode’s UI |
Available Slash Commands
| Command | Description |
|---|---|
|
Compact session context (summarise and prune) |
|
Start a new session |
|
Resume a session by ID or fragment |
|
Fork the current session |
|
Select a different LLM model |
|
List loaded skills |
|
Show session tree |
|
Initialise project config ( |
|
Show all available commands |
Commands with rendering == TUI_ONLY are excluded from this list โ they are not meaningful outside the terminal UI.
Model Selection & Reasoning Effort Pickers
Xcode renders native model and reasoning effort selection pickers based on the configOptions advertised by Book.
When you select a model or reasoning effort level in Xcode’s UI:
-
Xcode issues a
session/set_config_optionJSON-RPC call (configId: "model"orconfigId: "thought_level"). -
For model changes, Book validates the requested model against configured API keys, updates the model on the agent loop, and sends a
SessionUpdate.ConfigOptionUpdateand an immediateSessionUpdate.UsageUpdateto update Xcode’s context window usage meter. -
Model changes requested while a prompt turn is active are rejected with an error; changing model while idle succeeds immediately.
Session Persistence
Each session/new request creates a new Book session stored in the default session directory. Sessions created via Xcode are identical to sessions created from the terminal โ they appear in bk sessions list output and can be resumed from either interface.
Use session/load (triggered by Xcode’s session restore UI) to continue a previous conversation, including full message history.
Troubleshooting
Xcode shows "Agent failed to initialize"
-
Open Terminal and run:
bash
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"0.26","clientCapabilities":{}}}' \
| bk serve
`
You should see a JSON response on stdout. If you see an error, check the logs under `~/.bk/agent/logs/ for details.
-
Confirm
OPENAI_API_KEYis set:
`bash grep OPENAI_API_KEY ~/.bk/config `
Xcode shows a non-JSON line before the first response
The first line kotlin-logging: initializing… is printed by the logging framework before the log redirect takes effect. This is cosmetic โ ACP-compliant clients must ignore any non-JSON lines on stdout per the ACP transport spec. As a workaround:
java -Dkotlin-logging.init=false -jar ~/.local/bin/bk.jar serve
Tool calls are not visible in Xcode
Book emits session/notifications/update messages with tool_call type for each tool execution. If Xcode does not display them, ensure you are running Xcode 26.6 or later.
Sessions created via Xcode don’t appear in bk sessions list
Sessions are stored relative to the working directory Xcode passes in session/new โ params.cwd. Run bk sessions list --all to list sessions across all directories.
Known Limitations (v1)
| Limitation | Status |
|---|---|
No MCP server pass-through at startup |
MCP config arrives per-session via |
No HTTP/WebSocket transport |
|
|
Cosmetic โ see Troubleshooting above |
|
|