Headless Runs
Run one session from a script without the terminal UI, on the harness or an agent CLI, and read its outcome.
agentty run runs one session without the terminal UI, on the native harness or on an agent CLI such as Claude Code. The session takes the same path as one you start in the terminal: the same prompts, tools, worktree, commits, focused review, and transition to Review. It is stored in Agentty's database, so you can open it in the terminal UI afterwards. Like the terminal UI, it needs the Agentty root to itself, so close the terminal UI first.
Run a Session🔗
Pass the project's checkout, a harness model id from /model, and the first message:
agentty run --project ~/code/app --model muse-spark-1.3 \
--prompt "Add a --verbose flag and a test for it" \
--follow-up "Update the README for the flag" \
--json-out run.json| Option | Purpose |
|---|---|
--agent KIND | Backend: harness (default), claude, codex, or antigravity. |
--prompt TEXT, --prompt-file FILE | First message; give exactly one. |
--follow-up TEXT | Message sent once the previous turn reached Review; repeatable. |
--effort LEVEL | Reasoning effort: low, medium, high, xhigh, or max. |
--answer-questions first|fail | Answer each question with its first option, or stop (default). |
--json-out FILE | Write a JSON summary of the run. |
--otlp-endpoint URL | Export traces as the terminal UI does; see Telemetry. |
The model must be available to the harness, so set its provider's key first; see Backends. To run the session on an agent CLI instead, name it with --agent and pass one of its /model ids; the CLI must be on PATH and signed in:
agentty run --project ~/code/app --agent claude --model claude-sonnet-5-5 \
--prompt "Add a --verbose flag and a test for it"A model the agent does not offer stops the run and lists the ones it does. Prompts, answers, workflow notices, and progress lines stream to standard output as the session runs. The run waits for each turn's commit and focused review, including turns that apply review suggestions automatically, before it sends the next message.
Exit Codes🔗
| Code | Meaning |
|---|---|
0 | Every message ran and the session waits in Review. |
1 | The run could not start or report, such as for an unavailable model. |
2 | The arguments are invalid. |
3 | A turn failed. |
4 | A turn was cut off: a run limit, the context window, or a repetition stop. |
5 | The session asked a question the run did not answer. |
A failed or cut-off turn ends the run without sending later follow-ups. On an agent CLI, a turn failed, or was cut off when it was stopped, only when it left its backend's error. A turn that completes without answer text or changes still counts as run, and the next message is sent.
JSON Summary🔗
--json-out writes the session's id, agent, and model, the outcome, the latest answer, open questions, the failure kind of the last turn, each turn's status, the focused_review, token and cost totals, wall time, and the diff stat against the base branch. tokens holds input, output, and, when the backend reports them, cache_read, cache_write, and reasoning. requests lists the model requests of completed turns with their finish_reason, and rejected_tool_calls lists the tool calls the harness answered with an error instead of running. A failed turn records only its failure kind, not its requests.
Agentty reads turns, requests, and rejected_tool_calls from the harness, so they are empty on an agent CLI, where failure is the notice the failed turn left in the transcript.