Exit codes
Reference
The process exit codes of mare for headless runs, RPC and ACP servers, the interactive interface and subcommands, and the reason values of the final settled record.
This reference page is maintained by hand (not generated by
scripts/gen_docs.py).
Headless runs
Section titled “Headless runs”mare -p and mare --json finish with one of these codes. With --json, the same code and a matching reason appear in the last record (see JSON event stream).
| Code | settled.reason |
Meaning |
|---|---|---|
| 0 | completed |
The turn finished without an error. |
| 1 | error |
A provider, tool or runtime error. Also a session that -c or --resume could not find, and SIGTERM or SIGHUP. |
| 2 | usage |
Bad arguments or configuration: an unknown flag, no prompt, an unreadable stdin, a failing init.lua, a config warning under --strict-config, or a trust problem. The run never started. |
| 3 | approval_unavailable |
An approval was answered with “deny and stop” (abort) and the turn was stopped. |
| 4 | max_turns |
--max-turns was reached. |
| 4 | timeout |
--timeout was reached. |
| 5 | save_failed |
Session persistence failed. Any final answer is still written to stdout, unsaved records are written to <state>/quarantine/, and a warning is printed to stderr. |
| 130 | interrupted |
SIGINT (Ctrl+C). |
| 141 | none | Stdout was closed by the reader, for example mare --json ... | head. The turn is stopped and no settled record is written. |
Some notes on how these are chosen:
- Code 3 is only for runs that stopped because an approval was answered
abort. An approval nobody could answer is a denied call, not a stop: the model gets the denial, and if it works around it the turn completes with 0. Every denial is listed on stderr, whatever the exit code. --timeoutbounds the whole run, including delivering output. When it fires, mare cancels the turn, tries to writeturn.failedandsettled(withtimeout) and exits 4. If the reader of stdout is blocked, the stream can end without them, so treat a missingsettledas a failure.- The first SIGINT cancels the turn and finishes normally with 130. A second SIGINT exits at once with 130 and writes no
settledrecord. - A usage error under
--jsonstill printssession,turn.failedandsettledlines so a script reading the stream always gets an outcome. --timeoutis refused with 2 outside headless runs (-pand--json).
mare -p --timeout 5m --max-turns 30 "Fix the failing tests"case $? in 0) echo done ;; 3) echo "stopped by an approval abort: rerun with a permission preset that allows it" ;; 4) echo "ran out of turns or time" ;; *) echo "failed" ;;esacServers and the interface
Section titled “Servers and the interface”| Mode | Code | When |
|---|---|---|
mare --rpc |
0 | Stdin closed, shutdown received, or SIGTERM or SIGINT. |
mare --rpc |
2 | Config warnings under --strict-config, a broken init.lua, or a trust problem at startup. mare writes the message to stderr. |
mare acp |
0 | The editor closed the connection. |
| Interactive | 0 | Normal quit, or SIGTERM during startup. |
| Interactive | 130 | SIGINT before the interface took over. |
| Interactive | 2 | You chose to quit from the startup dialog for a failing config file. |
Subcommands
Section titled “Subcommands”| Command | Codes |
|---|---|
mare doctor |
0 when every check passes, 1 when any check fails. --json uses the same codes. |
mare session ... |
new, list, fork, archive, unarchive, delete: 0 on success (new and fork print the id); 1 when new creates no session, delete is cancelled, or an operation fails; 2 for invalid --limit, an unresolved or ambiguous session selector, or delete without --yes on non-TTY stdin. |
mare test |
0 when all tests pass, 1 when one or more test cases fail, 2 on usage, spec discovery, host startup, or spec load/syntax errors. |
mare token rotate |
0 on success, 1 on failure. |
mare web url |
0 on success (prints the ?token= login URL), 1 when no listener is running or token lookup fails. |
mare login, mare logout, mare model refresh |
0 on success, 1 on failure, 2 when the host could not start or --with-api-key has no key on stdin. |
mare mcp ... |
0, or 1 when the action reports a config error or a failure. |
mare peer send |
0 once the receiving session accepted the message (it prints held, delivered or handled). 1 for a missing target, a refused message or no answer within 30 seconds. |
mare sandbox status |
0. With --require-full, 1 unless all sandbox isolation capabilities are fully enforced (currently exits 1 on Windows even when the enhanced self-test passes because per-call network isolation is not enforced). |
mare sandbox setup |
0 on success, 1 on failure. 2 on platforms other than Windows. |
mare trust, mare init, mare runtime, mare plugin ..., mare completion, mare rpc schema |
0 on success. Any error is reported on stderr with exit code 1. |
Argument errors from the command-line parser itself, such as an unknown subcommand, exit with 2. A crash that ends the process writes a report under <state>/crashes/ and exits non-zero (see Files).