RPC Mode

September 20, 2026 · View on GitHub

RPC mode enables headless operation of the coding agent via a JSON protocol over stdin/stdout. This is useful for embedding the agent in other applications, IDEs, or custom UIs.

Note for Node.js/TypeScript users: If you're building a Node.js application, consider using AgentSession directly from @bastani/atomic instead of spawning a subprocess. See src/core/agent-session.ts for the API. For a subprocess-based TypeScript client, see src/modes/rpc/rpc-client.ts.

Where to go next

This page starts RPC mode and walks one client end to end. The rest is split by job:

Not sure RPC is the right integration mode? Compare it with the SDK and JSON mode on Programmatic use.

Starting RPC Mode

atomic --mode rpc [options]

Common options:

  • --provider <name>: Set the LLM provider (anthropic, openai, google, etc.)
  • --model <pattern>: Model pattern or ID (supports provider/id and optional :<thinking>)
  • --name <name> / -n <name>: Set the session display name at startup
  • --no-session: Disable session persistence
  • --session-dir <path>: Custom session storage directory

Protocol Overview

  • Commands: JSON objects sent to stdin, one per line
  • Responses: JSON objects with type: "response" indicating command success/failure
  • Events: Agent events streamed to stdout as JSON lines

All commands support an optional id field for request/response correlation. If provided, the corresponding response will include the same id.

A complete saved provider/model default can block prompts if its provider remains unsupported after registration. The process stays live, but prompt returns a correlated error with the generic configuration diagnostic before emitting any user/model event. get_available_models and other non-prompt commands remain available.

Clear this condition with a successful explicit set_model or a successful cycle_model that returns a different available model. A null or unchanged cycle result does not clear it. Replacing the session applies the new session's condition again.

Supported providers with an unknown model or missing authentication retain ordinary automatic fallback behavior.

Framing

RPC mode uses strict JSONL semantics with LF (\n) as the only record delimiter.

Atomic does not impose a size limit on RPC or isolated interactive-engine JSONL records. Commands, responses, events, and render frames are serialized in full. Clients and extensions must account for the memory and latency cost of large records and must not add a smaller line limit unless they intend to reject valid Atomic output.

This matters for clients:

  • Split records on \n only
  • Accept optional \r\n input by stripping a trailing \r
  • Do not use generic line readers that treat Unicode separators as newlines

In particular, Node readline is not protocol-compliant for RPC mode because it also splits on U+2028 and U+2029, which are valid inside JSON strings.

Commands

Moved to RPC protocol.

Prompting

Moved to RPC protocol.

prompt

Moved to RPC protocol.

steer

Moved to RPC protocol.

follow_up

Moved to RPC protocol.

abort

Moved to RPC protocol.

clear_queue

Moved to RPC protocol.

new_session

Moved to RPC protocol.

State

Moved to RPC protocol.

get_state

Moved to RPC protocol.

get_messages

Moved to RPC protocol.

Model

Moved to RPC protocol.

set_model

Moved to RPC protocol.

cycle_model

Moved to RPC protocol.

get_available_models

Moved to RPC protocol.

logout_provider

Moved to RPC protocol.

Thinking

Moved to RPC protocol.

set_thinking_level

Moved to RPC protocol.

cycle_thinking_level

Moved to RPC protocol.

get_available_thinking_levels

Moved to RPC protocol.

Queue Modes

Moved to RPC protocol.

set_steering_mode

Moved to RPC protocol.

set_follow_up_mode

Moved to RPC protocol.

Compaction

Moved to RPC protocol.

compact

Moved to RPC protocol.

set_auto_compaction

Moved to RPC protocol.

Retry

Moved to RPC protocol.

set_auto_retry

Moved to RPC protocol.

abort_retry

Moved to RPC protocol.

Bash

Moved to RPC protocol.

bash

Moved to RPC protocol.

abort_bash

Moved to RPC protocol.

Session

Moved to RPC protocol.

get_session_stats

Moved to RPC protocol.

export_html

Moved to RPC protocol.

switch_session

Moved to RPC protocol.

fork

Moved to RPC protocol.

clone

Moved to RPC protocol.

get_fork_messages

Moved to RPC protocol.

get_entries

Moved to RPC protocol.

get_tree

Moved to RPC protocol.

get_last_assistant_text

Moved to RPC protocol.

set_session_name

Moved to RPC protocol.

Commands

Moved to RPC protocol.

get_commands

Moved to RPC protocol.

Events

Moved to RPC protocol.

Event Types

Moved to RPC protocol.

agent_start

Moved to RPC protocol.

agent_end

Moved to RPC protocol.

turn_start / turn_end

Moved to RPC protocol.

message_start / message_end

Moved to RPC protocol.

message_update (Streaming)

Moved to RPC protocol.

tool_execution_start / tool_execution_update / tool_execution_end

Moved to RPC protocol.

bash_execution_update

Moved to RPC protocol.

queue_update

Moved to RPC protocol.

compaction_start / compaction_end

Moved to RPC protocol.

auto_retry_start / auto_retry_end

Moved to RPC protocol.

summarization_retry_scheduled / summarization_retry_attempt_start / summarization_retry_finished

Moved to RPC protocol.

extension_error

Moved to RPC protocol.

Extension UI Protocol

Moved to RPC extension UI protocol.

Extension UI Requests (stdout)

Moved to RPC extension UI protocol.

select

Moved to RPC extension UI protocol.

confirm

Moved to RPC extension UI protocol.

input

Moved to RPC extension UI protocol.

editor

Moved to RPC extension UI protocol.

notify

Moved to RPC extension UI protocol.

setStatus

Moved to RPC extension UI protocol.

setWidget

Moved to RPC extension UI protocol.

setTitle

Moved to RPC extension UI protocol.

set_editor_text

Moved to RPC extension UI protocol.

Extension UI Responses (stdin)

Moved to RPC extension UI protocol.

Value response (select, input, editor)

Moved to RPC extension UI protocol.

Confirmation response (confirm)

Moved to RPC extension UI protocol.

Cancellation response (any dialog)

Moved to RPC extension UI protocol.

Error Handling

Moved to RPC protocol.

Types

Moved to RPC protocol.

Model

Moved to RPC protocol.

UserMessage

Moved to RPC protocol.

AssistantMessage

Moved to RPC protocol.

ToolResultMessage

Moved to RPC protocol.

BashExecutionMessage

Moved to RPC protocol.

Attachment

Moved to RPC protocol.

Example: Basic Client (Python)

import subprocess
import json

proc = subprocess.Popen(
    ["atomic", "--mode", "rpc", "--no-session"],
    stdin=subprocess.PIPE,
    stdout=subprocess.PIPE,
    text=True
)

def send(cmd):
    proc.stdin.write(json.dumps(cmd) + "\n")
    proc.stdin.flush()

def read_events():
    for line in proc.stdout:
        yield json.loads(line)

# Send prompt
send({"type": "prompt", "message": "Hello!"})

# Process events
for event in read_events():
    if event.get("type") == "message_update":
        delta = event.get("assistantMessageEvent", {})
        if delta.get("type") == "text_delta":
            print(delta["delta"], end="", flush=True)
    
    if event.get("type") == "agent_end":
        print()
        break

Example: Interactive Client (Node.js)

Moved to RPC client examples.