The agent Print, JSON and RPC modes

Print, JSON and RPC modes

Besides the terminal UI, Saetta Code has pi's three non-interactive modes, for scripts, CI and programs that drive the agent. All three use the same tools, context files, skills and session files as the interactive mode.

saetta code -p: one prompt, the answer printed

-p (--print) answers the prompt, prints the final text and exits:

shell
saetta code -p "fix the failing test"
saetta code -p --pack 27b-turbo "summarize what src/server.c does"
git log -20 --oneline | saetta code -p "write release notes from these commits"

Piped input is joined to the prompt, and makes the run a print run even without -p. The session is saved as usual (--no-session skips it), so saetta code -c can continue it in the terminal UI.

In a project that is not yet trusted there is no prompt to ask in, so project resources stay off; pass --approve to trust it for the run. See Context and skills.

JSON mode

--mode json prints pi's event stream instead of the text, one JSON object per line: the session header first, then the agent's events as they happen.

shell
saetta code --mode json -p "list the files in src" > events.jsonl
eventwhen
sessionfirst line: the session header (format version, id, timestamp, working directory)
agent_start, agent_endthe run starts and ends
turn_start, turn_endeach model call with its tool results
message_start, message_update, message_enda message is created, streams, is complete
tool_execution_start, tool_execution_update, tool_execution_enda tool runs, with partial and final output
compaction_start, compaction_endan automatic compaction
auto_retry_start, auto_retry_enda failed request is retried
queue_updatequeued steering or follow-up messages changed

Retries follow retry in settings.json (pi's keys and defaults: enabled true, maxRetries 3, baseDelayMs 2000, maxAgentDelayMs 60000).

RPC mode

--mode rpc is pi's rpc protocol: JSON commands on stdin, one per line, and on stdout a response to each command plus the session's events (the same events as JSON mode). It keeps running until stdin closes, so one process serves many prompts.

shell
saetta code --mode rpc
json
{"id": "1", "type": "prompt", "message": "add a --verbose flag to the CLI"}
{"id": "2", "type": "get_state"}
{"id": "3", "type": "abort"}

Each response carries the command's id, "type": "response", the command's name in command, and success with data, or "success": false with an error:

json
{"id":"2","type":"response","command":"get_state","success":true,"data":{...}}
commandwhat it does
promptsend a message (while streaming, streamingBehavior says whether it steers or follows up)
steer, follow_upqueue a steering or follow-up message
abort, clear_queuestop the turn, drop queued messages
get_state, get_messages, get_entries, get_tree, get_session_statsread the session
get_last_assistant_text, get_fork_messages, get_commandsthe last answer, the messages a fork can start from, the commands (MCP and skills)
new_session, switch_session, fork, clone, set_session_namemanage sessions
compact, set_auto_compactioncompact now, turn automatic compaction on or off
set_model, cycle_model, get_available_modelschoose the model
set_thinking_level, cycle_thinking_level, get_available_thinking_levelschoose the thinking level
set_steering_mode, set_follow_up_modeone-at-a-time or all
set_auto_retry, abort_retryretries of failed requests
bash, abort_bashrun a shell command into the context, stop it
export_htmlwrite the session as HTML

Saetta Code's rpc mode is compared with pi's on 12 recorded scenarios, driven by pi's own rpc client, so a program written against pi's rpc mode drives Saetta Code too. Extension UI requests never occur, since Saetta Code runs no extensions, and image input is not supported.

Edit this page on GitHub