RPC protocol
Commands
Stored summaries and workflow history
These read-only commands do not start a model turn. Stored summaries remain available whensessionSummary.enabled is false.
Workflow records include
runId, name, status, label, identity, summary, and summarizedThrough (Unix milliseconds). Optional summary fields are absent when no summary has been saved. list_workflow_runs accepts an optional status filter. Run detail requests accept full UUIDs for earlier sessions; a missing run returns the normal error response. Summaries describe progress through their marker and may be stale.
Stored history follows the SDK’s run-detail access rules: top-level runs with a recorded session owner launched from the current project directory. Runs from other project directories are not included.
Prompting
prompt
Send a user prompt to the agent. The command response is emitted after the prompt is accepted, queued, or handled. Events continue streaming asynchronously after acceptance.streamingBehavior to queue the message:
"steer": Queue the message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call."followUp": Wait until the agent finishes. Message is delivered only when agent stops.
streamingBehavior is specified, the command returns an error.
Extension commands: If the message is an extension command (e.g., /mycommand), it executes immediately even during streaming. Extension commands manage their own LLM interaction via pi.sendMessage().
Input expansion: Skill commands (/skill:name) and prompt templates (/template) are expanded before sending/queueing.
Response:
data.disposition is "handled" if an extension command or input handler consumed the prompt, "queued" if Atomic queued it during a run, held it because the message queue was paused before its run began, or held it because the session is compacting, or "started" if Atomic started a run for it. A prompt held during compaction is sent once compaction ends. If its turn then fails to start, for example because credentials were removed, Atomic keeps the message queued and emits an agent_continue_error event with source: "post_compaction". This describes the submitted prompt, not independent work started by an extension or a guarantee of completion. If it is "handled", no run started for this prompt, so don’t wait for agent_end or agent_settled.
success: true means the prompt was accepted, queued, or handled immediately. success: false means the prompt was rejected before acceptance. Failures after acceptance are reported through the normal event and message stream, not as a second response for the same request id.
The images field is optional. Each image uses ImageContent format: {"type": "image", "data": "base64-encoded-data", "mimeType": "image/png"}.
steer
Queue a steering message while the agent is running. It is delivered after the current assistant turn finishes executing its tool calls, before the next LLM call. If no run is active when it arrives and the session already has messages, Atomic starts a turn to deliver it, so aprompt sent while that turn runs needs streamingBehavior. On a session with no messages yet, or after a run was stopped with abort, it stays queued until the next prompt. Skill commands and prompt templates are expanded. Extension commands are not allowed (use prompt instead).
images field is optional. Each image uses ImageContent format (same as prompt).
Response:
data.disposition is "handled" if an input handler consumed this steer, or "queued" if Atomic queued it (including after a handler transformed it). It does not guarantee this message remains queued.
See set_steering_mode for controlling how steering messages are processed.
follow_up
Queue a follow-up message to be processed after the agent finishes. Delivered only when agent has no more tool calls or steering messages. If no run is active when it arrives and the session already has messages, Atomic starts a turn to deliver it, so aprompt sent while that turn runs needs streamingBehavior. On a session with no messages yet, or after a run was stopped with abort, it stays queued until the next prompt. Skill commands and prompt templates are expanded. Extension commands are not allowed (use prompt instead).
images field is optional. Each image uses ImageContent format (same as prompt).
Response:
data.disposition has the same "handled" or "queued" meaning as for steer, applied to this follow-up.
See set_follow_up_mode for controlling how follow-up messages are processed.
abort
Abort the current operation and wait for the session to become idle before responding.clear_queue
Remove queued steering and follow-up messages and return their text. The response lists exactly the messages this call removed. It includes a message queued after the lastqueue_update the client received, and leaves out one the session already took into a turn. A client that restores the queue to an editor should restore this list, not its own copy of the queue: the copy kept from queue_update events trails the session by a round trip.
steering and followUp list each message as queued, after input hooks, skills and prompt templates changed it. typed lists the same messages, in the same order, as they were submitted. A client that gives the messages back to the user to send again should restore typed, so those steps run once more and not twice. typed is left out when every message was queued as submitted, and by sessions from before it was added; restore steering and followUp then.
To implement interactive Esc behavior, send clear_queue before abort, then restore the returned text in the client editor. abort continues queued messages when they remain in the session.
new_session
Start a fresh session. Can be cancelled by asession_before_switch extension event handler.
delete_session
Delete a stored session and its entries from the active session store (SQLite or JSONL). Uselist_sessions to find IDs.
sessionId names the session to delete. id is the request ID that every command carries and is echoed in the response. When sessionId is omitted, id is also used as the session ID, so {"type": "delete_session", "id": "019fdf86-cf98-7327-8a73-21365028f6ae"} deletes that session and the response echoes the same id. When both are present, sessionId wins. Omitting both returns an error response (delete_session requires sessionId) and changes nothing.
Response:
RpcClient method: deleteSession(sessionId), which rejects on an error response.
State
get_state
Get current session state.model field is a full Model object or null. Its contextWindow is the model’s token budget. The sessionName field is the display name set via set_session_name, or omitted if not set.
get_messages
Get all messages in the conversation.AgentMessage objects (see Types).
Model
set_model
Switch to a specific model. Omitpersist (or set it false) to change only the current session. Set "persist": true to also save defaultProvider, defaultModel, and the effective thinking level in settings, matching an interactive /model selection.
cycle_model
Cycle to the next available model. Returnsnull when fewer than two authenticated models are available in the active scope or catalog. When an unsupported saved default is blocking prompts, a successful cycle that returns a different model clears that condition; a null or unchanged result does not. Set "persist": true to also write the cycled model as the startup default.
model field is a full Model object.
get_available_models
List all configured models.data also carries scopedModels, oauthProviders, customAuthProviders, and providerAuthStatuses. customAuthProviders lists extension-registered providers ({ id, name }) that accept an API key through login_provider. providerAuthStatuses lists the authentication status of extension-registered providers ({ provider, status }, where status is { configured, source?, label? }) when it does not come from a credential stored in auth.json, for example an environment variable. refresh_models responses carry the same fields.
The subprocess protocol returns full Model objects. The exported TypeScript RpcClient.getAvailableModels() keeps its smaller backward-compatible ModelInfo shape (provider, id, contextWindow, reasoning) and adds optional compat. When present, compat exposes constrained-sampling capability claims including supportsStrictTools, supportsStrictMode, canonical supportsOpenAIGrammarTools, and Atomic’s synchronized supportsGrammarTools alias. Treat absence as unknown/unsupported; do not infer enforcement from the provider name.
logout_provider
Remove a provider’s stored credential in the authoritative agent process, refresh its available-model catalog, and return the remaining authentication status and new catalog. Environment variables andmodels.json authentication are reported but are not modified.
models preserves the refreshed catalog order. scopedModels is optional. If authentication remains through an environment variable, authStatus.source is "environment" and authStatus.label names the variable.
Thinking
set_thinking_level
Set the reasoning/thinking level for models that support it. Omitpersist (or set it false) to change only the current session. Set "persist": true to also save defaultThinkingLevel and, when a model is active, its per-model override. Interactive /thinking choices request persistence automatically.
"off", "minimal", "low", "medium", "high", "xhigh", "max".
xhigh and max are available only when the active model’s capability mapping supports them; unsupported levels are clamped by the session model controls.
Response may omit data for compatibility with older clients:
thinking_level_changed state if an older acknowledgement arrives later. RpcClient.setThinkingLevel(level) remains a one-argument Promise<void> method.
cycle_thinking_level
Cycle through available thinking levels. Returnsnull data if model doesn’t support thinking.
get_available_thinking_levels
Return the thinking levels supported by the current model, in cycle order.Queue Modes
set_steering_mode
Control how steering messages (fromsteer) are delivered.
"all": Deliver all steering messages after the current assistant turn finishes executing its tool calls"one-at-a-time": Deliver one steering message per completed assistant turn (default)
set_follow_up_mode
Control how follow-up messages (fromfollow_up) are delivered.
"all": Deliver all follow-up messages when agent finishes"one-at-a-time": Deliver one follow-up message per agent completion (default)
Compaction
compact
Run verbatim line compaction with the session model. It preserves exactly the newestpreserve_recent context-visible messages, default two, without aligning to user turns. Zero compacts the whole active transcript and returns firstKeptEntryId: null. The resulting durable entry uses details.strategy: "verbatim-lines"; see Compaction for behavior and settings.
firstKeptEntryId is a string when at least one ordinary message remains outside compaction and null when none does. RPC clients must accept both values.
set_auto_compaction
Enable or disable automatic compaction when context is nearly full.Extension UI
set_extension_ui_capabilities
Say what extension UI the client can show. Withquestionnaire: true, ask_user_question reaches the client as one questionnaire request instead of failing for lack of a terminal. Off until the client turns it on; an omitted field keeps its value.
Retry
set_auto_retry
Enable or disable automatic retry on transient errors (overloaded, rate limit, 5xx).abort_retry
Abort an in-progress retry (cancel the delay and stop retrying).Bash
bash
Execute a shell command and add output to conversation context.id:
channel is exactly "stdout" or "stderr". Deltas preserve the observed order for each request. Concurrent bash requests may interleave globally but never share IDs.
Request ownership survives new_session, switch_session, import_session, fork, and clone while the command runs. Later deltas keep the original ID and do not contaminate the replacement session. Exactly one ordinary response is the terminal record for completion, cancellation, or error.
If output was truncated, includes fullOutputPath. Persisted bash output lives in the owner- and session-scoped temp tree (<tmpdir>/atomic-<uid>/<session-id>/), not at the temp root — see Tools for the layout, permissions, size cap, and retention:
fullOutputPath is null when the temp directory could not be created or the write was refused; treat it as absent rather than assuming a path exists.
How bash results reach the LLM:
The bash command returns a BashResult and saves output in the session where the request started, even if another session becomes active before completion. The saved BashExecutionMessage emits no event of its own.
The initiating session’s next prompt includes the output as user context in this format:
- Bash output is included in the LLM context on the next prompt, not immediately
- Multiple bash commands can be executed before a prompt; all outputs will be included
- No event is emitted for the
BashExecutionMessageitself
abort_bash
Abort running bash commands. OmitrequestId to retain the legacy behavior of aborting every active RPC-owned bash request, including requests that began before a session replacement, or provide the target bash command’s id to cancel only that request. Targeted and legacy cancellation remain isolated across concurrent IDs. Closing RPC cancels and drains remaining owned requests before shutdown.
Session
get_session_stats
Get token usage, cost statistics, and current context window usage.tokens contains assistant usage totals for the current session state. contextUsage contains the actual current context-window estimate used for compaction and footer display.
contextUsage is omitted when no model or context window is available. contextUsage.tokens and contextUsage.percent are null immediately after compaction until a fresh post-compaction assistant response provides valid usage data.
latestAssistantUsage is the usage reported by the newest assistant message, including an aborted or failed one; the interactive footer reads its cache-hit rate from it. It is omitted until the session has an assistant message.
get_tools
Explain which tools are active, which are not and why, and which selected tool names nothing registered."defaultTools": ["+codemode", "+tool-search"]:
selection.source is one of default-tools-setting, built-in-defaults, tools-allowlist, explicit-selection, no-built-in-tools, or no-tools; modifiers lists +name/-name entries from --tools. tools lists active tools first. excluded lists selected names that --exclude-tools or a mode without user input removed. The command waits until extensions finish loading, so the report includes their tools. RpcClient.getTools() returns the same data.
export_html
Export session to an HTML file.switch_session
Load a different session by its exact ID. Can be cancelled by asession_before_switch extension event handler. sessionLocation in get_state is optional display text, not a switch target.
sessionDirectory to bind the ID lookup to that directory. IDs may repeat in different project stores; an explicitly selected directory never falls back to another store. cwdOverride changes the resumed working directory, not the store used for lookup.
start_pending_recovery
Recover work an earlier process left unfinished in the current session. Send it after you have shown the transcript, at startup or afterswitch_session.
Loading or switching a session never recovers anything by itself. Until a client sends this command, interrupted deliveries stay pending in the session. The command runs once per loaded session; repeating it returns the same report. It does not block other commands, so prompts and abort keep working while it runs.
reason is optional and accepts "startup", "resume", or "workflow_stage_resume".
Extensions first restore their background work. Interrupted deliveries that are still wanted are then replayed in a turn, which streams like any other turn. Notices and undelivered background task results are appended without starting a turn.
The response arrives when recovery has finished:
fork
Create a new fork from a previous user message on the active branch. Can be cancelled by asession_before_fork extension event handler. Returns the text of the message being forked from.
clone
Duplicate the current active branch into a new session at the current position. Can be cancelled by asession_before_fork extension event handler.
get_fork_messages
Get user messages available for forking.get_entries
Get all session entries in append order, excluding the session header. Unlikeget_messages, this includes pre-compaction history and abandoned branches.
Entry IDs are stable in the append-only tree. Use the last entry ID you have seen as since to get only entries strictly after it, even across client restarts.
leafId is the id of the current leaf entry (null for an empty session), so a client can tell in one round trip whether the active branch moved. If since does not match any entry id, the response is success: false.
get_tree
Get the session as a tree of entries. Each node is{entry, children, label?, labelTimestamp?}. A well-formed session has a single root; orphaned entries (broken parent chain) also appear as roots.
get_last_assistant_text
Get the text content of the last assistant message.{"text": null} if no assistant messages exist.
set_session_name
Set a display name for the current session. The name appears in session listings and helps identify sessions.get_state in the sessionName field. To set the initial name when starting RPC mode, pass --name <name> or -n <name> to the atomic --mode rpc process.
Commands
get_commands
Get available commands (extension commands, prompt templates, and skills). These can be invoked via theprompt command by prefixing with /.
name: Command name (invoke with/name)description: Human-readable description (optional for extension commands)source: What kind of command:"extension": Registered viapi.registerCommand()in an extension"prompt": Loaded from a prompt template.mdfile"skill": Loaded from a skill directory (name is prefixed withskill:)
location: Where it was loaded from (optional, not present for extensions):"user": User-level (~/.atomic/agent/)"project": Project-level (./.atomic/)"path": Explicit path via CLI or settings
path: Absolute file path to the command source (optional)
/settings, /hotkeys, etc.) are not included. They are handled only in interactive mode and would not execute if sent via prompt.
Events
Events are streamed to stdout as JSON lines. Most events do not include anid; bash_execution_update is the deliberate exception and uses the originating bash request ID.
Event Types
agent_start
Emitted when the agent begins processing a prompt.agent_end
Emitted when the agent completes. Contains all messages generated during this run.turn_start / turn_end
A turn consists of one assistant response plus any resulting tool calls and results.message_start / message_end
Emitted when a message begins and completes. Themessage field contains an AgentMessage.
message_update (Streaming)
Emitted during streaming of assistant messages. Carries the streaming delta plus the latest cumulative usage.message_update has no cumulative message, and assistantMessageEvent has no partial. Build your message from message_start and deltas, then use message_end as the final authoritative message.
The top-level usage field carries the latest cumulative provider-reported usage; it may
remain zero until completion when a provider does not report usage during streaming. When
the provider reports an explicit end-of-turn signal (pi-ai’s AssistantMessage.endTurn,
for example OpenAI Codex end_turn), the update carries it as a top-level endTurn
boolean — present only when the provider reported one.
assistantMessageEvent field contains one of these delta types:
Example streaming a text response:
tool_execution_start / tool_execution_update / tool_execution_end
Emitted when a tool begins, streams progress, and completes execution.tool_execution_update events stream partial results (e.g., bash output as it arrives):
toolCallId to correlate events. The partialResult in tool_execution_update contains the accumulated output so far (not just the delta), allowing clients to simply replace their display on each update.
bash_execution_update
Emitted only for directbash and non-intercepted user_bash RPC execution. Each event is {type, id?, channel, delta} where channel is "stdout" or "stderr"; use id to keep concurrent streams separate. Tool-call bash continues to use tool_execution_update and its toolCallId.
queue_update
Emitted whenever the pending steering or follow-up queue changes.compaction_start / compaction_end
Emitted when default Verbatim Compaction runs, whether manual or automatic. The result records deletion targets and stats rather than a generated summary.reason field is "manual", "threshold", or "overflow".
reason was "overflow" and compaction succeeds, willRetry is true and the agent will automatically retry the prompt. Public prompt/RPC callers wait for that post-compaction continuation before the prompt is considered complete.
If compaction was aborted, result is null and aborted is true.
If compaction failed (e.g., API quota exceeded), result is null, aborted is false, and errorMessage contains the error description.
result and errorMessage are independent. A mid-turn post-tool compaction can commit a boundary and then fail the provider hard-input-limit gate, so one compaction_end may carry both a non-null result and an errorMessage. Treat the result as a committed durable boundary in that case; the error describes the follow-up request that was not sent.
If overflow recovery exhausts the same-model compact-and-retry attempt, compaction_end includes "unresolvedOverflow": true and an errorMessage. Workflow orchestration treats that signal as a context-length failure that can advance configured model fallback tiers.
There is no context_compact command; Atomic reports it as an unknown command. Use compact. Only compaction_start and compaction_end events are emitted.
auto_retry_start / auto_retry_end
Emitted when automatic retry is triggered after a transient error (overloaded, rate limit, 5xx).summarization_retry_scheduled / summarization_retry_attempt_start / summarization_retry_finished
Emitted when compaction planning or branch summarization retries after a transient provider error. These events use the same retry settings as automatic assistant-turn retries.source is "branchSummary" and no reason is present. The loop then emits:
extension_error
Emitted when an extension throws an error.Error Handling
Failed commands return a response withsuccess: false:
Types
Source files and installed definitions:node_modules/@bastani/pi-ai/dist/types.d.ts-Model,UserMessage,AssistantMessage,ToolResultMessagenode_modules/@earendil-works/pi-agent-core/dist/types.d.ts-AgentMessage,AgentEventsrc/core/messages.ts-BashExecutionMessagesrc/modes/rpc/rpc-types.ts- RPC command/response types, extension UI request/response types
Model
contextWindow is the model’s token budget used by Atomic’s local budgeting, footer/stats, and compaction logic.
UserMessage
content field can be a string or an array of TextContent/ImageContent blocks.
AssistantMessage
"stop", "length", "toolUse", "error", "aborted". A streaming message carries "pending" until the terminal event replaces it, so a client that switches on the reason needs that case; a completed message never carries it. On the wire the pending reason appears on the message_start message — message_update frames carry no message at all — and message_end carries the terminal reason. A provider that reports an explicit end-of-turn signal (pi-ai’s AssistantMessage.endTurn, for example OpenAI Codex end_turn) sets endTurn: true on the assistant message; message_update frames echo it as a top-level boolean only when the provider reported one.
ToolResultMessage
BashExecutionMessage
Created by thebash RPC command (not by LLM tool calls):