Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

RPC mode

RPC mode runs micro without a terminal interface. It reads JSON objects from standard input and writes responses and agent events to standard output, one object per line.

micro --rpc -C /path/to/project -m opus

The process keeps one active session until standard input closes. Session commands can replace it. Model turns and RPC shell commands use the same provider, tools, sandbox, session storage, and agent loop as interactive mode.

Framing

Each input object must fit on one line and contain a type field:

{ "type": "get_state", "id": "state-1" }

The optional id is copied to the command response:

{
  "type": "response",
  "id": "state-1",
  "command": "get_state",
  "success": true,
  "data": { "model": "..." }
}

Failed commands use success: false and an error field. An unreadable input line produces a failed response and does not terminate the process.

JSON strings may contain escaped newlines. Records themselves are separated by the ASCII newline character.

Send a prompt

{ "type": "prompt", "id": "p1", "message": "explain the request path" }

micro first acknowledges the command, then streams serialized AgentEvent objects. The acknowledgement's data.disposition says what became of the prompt: "started" when a run began for it, or "queued" when it arrived during a run and waits for that run to finish. Either way the response confirms acceptance, not completion.

{"type":"response","id":"p1","command":"prompt","success":true,"data":{"disposition":"started"}}

Common event types include:

agent_start        turn_start         message_start
message_delta      message_end        tool_start
tool_update        tool_end           turn_end
agent_end          agent_settled      retry

The agent_end event contains the messages produced by the complete run. agent_settled means no turn or queued follow-up remains.

Control a running turn

These commands are handled while a turn is active:

{"type":"steer","id":"s1","message":"focus on the provider boundary"}
{"type":"follow_up","id":"f1","message":"then list the relevant tests"}
{"type":"clear_queue","id":"c1"}
{"type":"abort","id":"a1"}

steer reaches the active run at its next steering boundary. follow_up waits behind the active turn. Both answer with data.disposition set to "queued". A prompt sent during a turn is queued as a follow-up and answered the same way. abort drops the active turn and anything queued behind it.

clear_queue removes every queued steering and follow-up message, unsent, and returns their text:

{"type":"response","id":"c1","command":"clear_queue","success":true,"data":{"steering":["focus on the provider boundary"],"follow_up":["then list the relevant tests"]}}

To let a user take back what they queued, send clear_queue before abort and restore the returned text in the client's editor.

Other commands received during a turn are held until that turn finishes.

Images

prompt, steer, and follow_up accept base64-encoded images:

{
  "type": "prompt",
  "message": "describe this diagram",
  "images": [{ "data": "iVBORw0KGgo...", "mime_type": "image/png" }]
}

Commands

TypeRequired fieldsResult
promptmessageStart a model run.
steermessageAdd direction to the active run.
follow_upmessageQueue another prompt in the same run.
abortnoneStop the active run or clear queued prompts.
clear_queuenoneRemove queued steering and follow-up messages and return their text.
new_sessionnoneCreate and switch to a new session.
get_statenoneReturn model, provider, thinking, session, and queue state.
set_modelprovider, model_idSelect an exact catalog model.
cycle_modelnoneSelect the next catalog model.
get_available_modelsnoneReturn catalog models and limits.
set_thinking_levellevelChange reasoning effort, clamped to the model's levels; returns the level in use.
cycle_thinking_levelnoneSelect the next level the model offers; data is null when it does not reason.
get_available_thinking_levelsnoneReturn the model's levels, from least to most reasoning.
compactnoneCompact the conversation immediately.
set_auto_compactionenabledEnable or disable automatic compaction.
bashcommandRun sh -c under the active session sandbox.
abort_bashnoneAcknowledge the request; RPC bash commands are not background jobs.
get_session_statsnoneReturn session metadata and message count.
switch_sessionsession_pathLoad the path stem as an ID from micro's configured session store.
navigate_treeentry_idMove the current session head to an earlier entry.
forkentry_idCopy a branch into a new session.
clonenoneDuplicate the current session at its current head.
get_entriesnoneReturn entries; optional since starts inclusively at a known ID.
get_treenoneReturn the branch outline.
get_last_assistant_textnoneReturn the latest non-empty assistant text.
set_session_namenameRename the session.
get_messagesnoneReturn the current agent messages.
get_commandsnoneReturn built-in slash commands with source builtin.

The bash command accepts exclude_from_context: true when its output should not be added to the model conversation.

RPC bash uses the active session sandbox. Under the default workspace-write policy, it cannot write outside the workspace or use the network.

set_model and cycle_model rebuild the provider client, credentials, context limits, summarizer, and budget pricing. A session can switch between providers without restarting the RPC process.

If get_entries.since is unknown, the command returns an empty list. get_commands does not include commands supplied by skills, prompt templates, or extensions.

Project trust

RPC mode cannot ask an interactive trust question. Use a saved decision, --approve, or --no-approve when the project contains .micro/ resources. The command sandbox applies to model-invoked tools, brokered extension commands, and RPC bash.

Minimal client

A shell pipeline is enough for simple requests:

printf '%s\n' \
  '{"type":"get_state","id":"1"}' \
  '{"type":"prompt","id":"2","message":"summarize src/"}' \
  | micro --rpc -q

A long-running client should parse every output line, route objects with type: "response" by id, and process agent events independently.