ACP Server Configuration
Book implements the Agent Client Protocol (ACP) as an ACP server. IDE clients (such as Xcode) connect to Book over stdio, open sessions, send prompts, and receive streaming responses โ all via the ACP JSON-RPC wire protocol.
This page covers running and configuring the ACP server. For registering Book inside Xcode, see Xcode Integration. For the server architecture internals (AcpServer lifecycle, per-session isolation, capability-driven environment), see Embedding Book as an ACP Agent (Phase 4).
Starting the ACP Server
There are two entry points:
# Recommended: explicit flag form
bk --mode acp
# Deprecated sub-command form
bk serve # DEPRECATED: Use 'bk --mode acp' instead
Both delegate execution to AcpModeRunner.run(…) which handles background extension job synchronization, stdout stdio protection, and calls AcpServer.start(…).
Transport Flags
| Flag | Values | Default | Notes |
|---|---|---|---|
|
|
|
Use |
|
any hostname |
|
Bind address for |
|
any port number |
|
TCP port for |
Note:
--acp-transport httpthrowsNotImplementedErrorin the current release โ the ACP SDK (v0.25.0) does not yet ship an HTTP transport. This flag is reserved for a future release.
--mode Flag Interaction
--mode is a repeatable enum option (tui, acp, mcp). When multiple values are passed:
-
--mode acpand--mode tuitogether: a warning is emitted and ACP wins. -
--mode acpand--mode mcptogether:--mode mcpis silently ignored at startup โ MCP server config arrives per-session viasession/new.
Per-Session _meta Configuration
Clients that support the ACP _meta field can pass per-session configuration knobs in the session/new or prompt request body. AcpMetaParser parses the following book.* keys:
| Key | Type | Description |
|---|---|---|
|
|
Maximum number of agent turns before stopping. |
|
|
Maximum consecutive unproductive turns. |
|
|
Maximum turn age for |
|
|
Disable message-history pruning pipeline for this session. |
|
|
Compaction trigger threshold (0.0โ1.0). |
Example _meta payload:
{
"book.maxTurns": 10,
"book.maxUnproductiveTurns": 3,
"book.cacheMaxTurnAge": 2,
"book.disablePruning": false,
"book.compactionThresholdFraction": 0.75
}
All keys are optional. Absent or unrecognised keys are silently ignored. Returns null when _meta is absent, not a JsonObject, or contains no book.* keys โ the hasAnyOverride() guard prevents callers from receiving a semantically-empty config instance.
Session Configuration Options
Book advertises native session configuration options to ACP clients, allowing IDE pickers (such as IntelliJ IDEA, Xcode, Junie, or Zed) to directly select the model and reasoning effort.
-
Model option (
model): Lists the models returned by the provider’slistModels()call โ the provider is the source of truth. The localModelMetadataRegistryis used only as a cross-reference (context window, pricing) and as a fallback seed if the provider fetch has not completed yet. -
Reasoning effort option (
thought_level): Offers reasoning effort levels (off,minimal,low,medium,high,xhigh,max) corresponding toEffortLevelvalues. -
Usage Update Suppression:
SessionUpdate.UsageUpdateevents are only emitted when the model’s context window size is known (size > 0); models with unknown or zero context windows suppress usage updates to prevent misinformation.
Background Model Refresh & Sync
-
Hybrid Seed-Then-Refresh: Sessions start with a synchronous local model list seed to ensure instant client responsiveness. Immediately after session initialization (
postInitialize()), a background refresh callsagentLoop.listModels()to fetch live model metadata. On success with non-empty results, the picker list is updated and aSessionUpdate.ConfigOptionUpdateis pushed to the client. On failure or empty results, the local seed is retained silently with a warning log (silent degradation). -
Slash-Command Synchronization: Executing
/modelor/effortslash commands in ACP mode updates the session configuration and automatically notifies client pickers via a shared guarded emission helper. -
Emission Safety: All option-update emissions route through a single guarded helper (
emitConfigOptionUpdate) usingtrySendwith error logging; post-session/deleteemissions become logged no-ops.
When a client sends session/set_config_option:
-
Model switches (
model): Validated against the provider’s advertised model list (a model not offered by the provider is rejected) and rejected if a prompt turn is active (IllegalStateException). On success, updatesagentLoop.setModel(modelId), emits aSessionUpdate.ConfigOptionUpdatewith refreshed options, and emits an immediateSessionUpdate.UsageUpdateto rescale the client context usage meter. -
Reasoning effort switches (
thought_level): Case-insensitively mapped toEffortLevel, setssessionEffortandagentLoop.setThinkingLevel(…), re-emitsSessionUpdate.ConfigOptionUpdate, and returns updated options. -
No
session/set_config_optionoperation writes to persistent storage (configManager/sessionOrchestrator).
ACP Heartbeat Interval
While a tool process runs under ACP, a concurrent heartbeat emits Stdout(".") every 10 s. The period can be overridden at process startup via an environment variable:
| Env var | Type | Default | Constraint |
|---|---|---|---|
|
integer (seconds) |
|
Must be |
Example โ set a 30-second heartbeat interval:
BOOK_ACP_HEARTBEAT_INTERVAL=30 bk --mode acp
Streaming limitation: full terminal output is only available after the command exits โ real-time stdout streaming is not supported by the ACP terminal RPC surface.
Slash Commands in ACP Mode
In ACP mode, slash commands are routed through the domain SlashCommandRegistry (not the TUI’s SlashCommandRouter) and rendered back to the client as ACP events. Commands with rendering == TUI_ONLY are excluded from the ACP-visible command list โ they are not meaningful outside the terminal UI. See the command list in Xcode Integration.
Troubleshooting
-
Agent fails to initialize โ check
~/.bk/agent/logs/; a missingOPENAI_API_KEYis the most common cause. -
Non-JSON line before the first response โ
kotlin-logging: initializing…is cosmetic; ACP-compliant clients must ignore non-JSON stdout lines. -
Tool calls not visible โ requires Xcode 26.6+.
-
Sessions not listed โ sessions are stored relative to the
cwdthe client passes insession/new; runbk sessions list --all.