
Transcript
An unattended PanCode run with JSON output
Recorded with PanCode 0.9.1. Each section is the terminal screen at that moment.
== answer
~/projects/calibration-lab $ pancode run --output-format stream-json "Run the test check and report how many tests pass." > run.jsonl; echo "exit $?"
exit 0
~/projects/calibration-lab $ jq -r 'select(.type == "run_end").result.text' run.jsonl
The test check reports 6 passing tests and 1 failure. The failing test is “absolute zero”: `kelvinToCelsius(0)` throws `RangeError`.
~/projects/calibration-lab $
== run-end
"tools": {
"calls": 3,
"refused": 0,
"writes": 0
},
"safety": {
"decisions": {
"allowed": 3,
"blocked": 0,
"guardBlocked": 0,
"permissionRequested": 0
},
"blockedAttempts": []
},
"verify": {
"requested": 0,
"checks": []
},
"dispatch": {
"runs": [],
"live": [],
"undelivered": []
},
"timings": {
"sessionReadyMs": 938,
"firstRequestMs": 2212,
"firstTokenMs": 5320
}
}
~/projects/calibration-lab $You can start a task and leave. Headless pancode run does one turn with nobody attached, and the limits you set are enforced. This guide covers a bounded headless run, a read-only one, the timeouts that apply when you walk away from an open session, and scheduled turns.
Before you start
- PanCode installed, with a connected model.
- A Git repository, and a task you can state completely in one prompt.
Hand it work and walk away
Put your decisions in the prompt
The judge reads only your prompt in a headless run, so name the actions the job needs:
Shell
pancode run --max-cost-usd 2 --timeout 30m \ "Fix the failing parser test, run the test check, and commit on this branch. Do not push."--max-cost-usdcaps the priced spend this run adds. Reaching it stops the run and its workers with exit 4. Calls already in flight can pass the cap, and unpriced routes cannot be bounded, so pair it with--timeout, which exits 124 on expiry. The session ceiling, 5 USD by default, still applies.--require-pricedrefuses a run that could reach a route with no price.--max-requests <n>and--max-tool-calls <n>cap the main agent's model requests and tool calls, and each exits 4 when reached.--dry-runprints the route, tools, and limits the run would use, then exits 0 without calling a model.Ask a question that cannot change anything
Shell
pancode run --read-only "Which modules have no tests? Report paths."--read-onlyis an enforced ceiling on the main agent, not a request. No file outside PanCode's home changes: writes are refused, and shell commands run only in a read-only sandbox.Stream it to another program
Shell
pancode run --output-format stream-json "Summarize the last five commits."The stream opens with a
sessionframe carrying its schema version and ends with onerun_endframe. That frame holds the answer inresult.text, theexitCode, theoutcome, and thecausesthat ended the run. Read the result from it.When you want only the result,
--output-format jsonprints thatrun_enddocument alone, and-o answer.txtalso saves the answer to a file when the run exits 0.run --jsonwas removed; use--output-format stream-json.Continue later with
--continueor--resume <id>. Add--forkto branch a new session and leave the original as it was.Walk away from an open session
In the terminal, an unanswered approval card is denied after
safety.unattendedAfterMs(5 minutes by default) and the turn continues. A question takes its recommended option. Any key stops the countdown. When you return,/decisionsshows what was chosen, and the exit summary counts it on anUnattendedline.Schedule turns while idle
/loop 30m Check the nightly build log and report anything new. /loop 5m --command make check /loopA bare
/looplists the jobs. A loop runs only while its conversation is idle and never replays missed runs. The--commandform polls a program directly, with no shell.
What you should see
A finished turn with its exit code, not a parked prompt. An exit of 4 means a limit such as the cost ceiling stopped it. pancode telemetry why-stopped <session> explains a stop afterward.
Read how a run ended
Stderr names the session and prints an observed: line that counts tool calls, refusals, writes, and checks, plus a one-line summary of the outcome, requests, tokens, and cost. A script should read the exit code or the run_end frame, not the prose answer.
When --max-cost-usd meets a route with no price, stderr says the cap cannot bound it; declare connections[].pricing to fix that.
In a separate run of the first step, made for this guide apart from the session at the top of the page, Claude Haiku 5.5 on the anthropic-max route worked on a repository with one failing parser test. It split each line at the first =, ran the test check, committed on the branch, and pushed nothing.
That route carries a price estimate, so --max-cost-usd could bound it and stderr printed no unpriced-route notice. Stderr read:
pancode run: session n5iuvnc76u7o
pancode run: observed: 8 tool calls, 0 refused · 1 write · checks passed: npm run test, git statusOn a route with no price, such as a gateway connection without connections[].pricing, the same command first prints pancode run: --max-cost-usd does not bound unpriced routes: <connection>/<model>; declare connections[].pricing to bound them.
The run_end frame of the third step has this shape. causes is empty on success and lists every reason, most important first, when the run failed or was stopped:
JSON
{"type":"run_end","schemaVersion":2,"mode":"main","sessionId":"<id>","exitCode":0,"outcome":"succeeded","causes":[],"result":{"text":"<answer>","artifacts":[]}}The real frame carries more fields, such as usage, timings, and tool counts. pancode schema run-result prints the full JSON Schema.
| Exit | What it means |
|---|---|
0 |
The run settled and succeeded |
1 |
It failed: the model was unreachable, a worker did not deliver, or a refused call left the task undone. --fail-on-verify adds a failed --verify check |
2 |
A usage error, including --autonomy yolo as root outside a container |
3 |
At yolo, the safety judge blocked too many calls in a row; review the run, then --continue. Also --on-permission fail at the first request nobody could approve |
4 |
A cost ceiling, --max-requests, --max-tool-calls, or at yolo an autonomous cap on tool calls, minutes, or tokens, stopped it; --continue resumes |
124 |
--timeout expired; the run still settled and sealed |
130, 143 |
Ctrl+C or a SIGTERM stopped it |
Pick the right tool
| When you want | Use | What still stops it |
|---|---|---|
| One bounded task | pancode run at default |
Judge, sandbox, cost ceiling, timeout |
| A long job you leave running | pancode run --autonomy yolo |
Contained by default: the sandbox and judge stay on, and a call the judge does not allow is refused back to the run. Ceilings, timeout, the loop guard, and the tool budget also stop it |
| A recurring check | /loop in an open session |
Pause or stop it; needs the session to stay open |
Boundaries
- A contained command starts without credential variables and cannot open secret files, so name tools that need them. PanCode may rerun with
unsandboxed: true, which the judge reviews. At unconfinedyoloundersafety.sandbox: required, that retry is refused. yolodoes not carry over fromsettings.yamlto a headless run. It comes only from that run's own--autonomy yolo, and it exits 2 as root outside a detected container.