Skip to content

Output and errors ​

Last updated Nov 30, 2026 View as Markdown

JSON output ​

With --json, a command prints JSON on stdout and nothing else; messages and progress stay on stderr. Most commands print one document:

terminal
sh
pandra ps -a --json
text
{"schema_version":"1.0","sessions":[{"session_id":"9f2c4e1a7b3d5c6e8f90a1b2c3d4e5f6","name":null,"agent":"github.com/acme/reviewer","package_digest":"sha256:4f2a9c1e7b3d5a6f8e0c1b2a3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f67","harness":"claude-code","state":"idle","last_run_outcome":"completed","workspace":"/home/me/project","created_at":"2026-11-07T06:12:03Z","updated_at":"2026-11-07T06:14:41Z"}],"warnings":[]}
  • Every document carries schema_version. A new field or event type raises the minor version, so ignore fields you do not know.
  • Every documented field is present: null when it does not apply, [] when it is empty. IDs and digests are complete, and timestamps are RFC 3339 in UTC.
  • Secret values that Pandra resolves never appear. An agent's answer is passed on as the agent wrote it, and can contain anything the agent saw.
  • pandra schema lists the JSON Schema of every document and event (schemas).

Outside a dry run, --json makes run and resume headless, and --tui rejects it.

The event stream ​

run and resume with --json print one JSON event per line, as it happens. By default the stream is a handful of lines, so a calling agent's context stays small:

terminal
sh
pandra run github.com/acme/reviewer@v1.2.0 --harness claude-code \
    --prompt "Review PR 12." --output-schema findings.schema.json --json
text
{"type":"version","schema_version":"1.0"}
{"type":"progress","phase":"preparing"}
{"type":"session","session_id":"9f2c4e1a7b3d5c6e8f90a1b2c3d4e5f6","name":null,"agent":"github.com/acme/reviewer","package_digest":"sha256:4f2a9c1e7b3d5a6f8e0c1b2a3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f67","harness":"claude-code","workspace":"/home/me/project","backend":"host"}
{"type":"progress","phase":"starting"}
{"type":"progress","phase":"running"}
{"type":"answer","text":null,"data":{"findings":[{"file":"src/auth.rs","line":42,"message":"Token compared with ==","severity":"high"}]}}
{"type":"result","session_id":"9f2c4e1a7b3d5c6e8f90a1b2c3d4e5f6","outcome":"completed","exit_code":0,"usage":{"input_tokens":18432,"output_tokens":912,"cached_input_tokens":15360,"cost_usd":0.0421},"skills":{"loaded":["review"],"preloaded":[],"not_loaded":["pandra","simplify"],"loaded_in_run":["review"]}}
EventWhen
versionAlways first.
sessionWhen the session exists, before the harness starts.
progressAt coarse phases: fetching, building, preparing, starting, running.
warningSomething needs attention, but the run continues.
answerThe final answer: text, or data with --output-schema.
errorPandra or the harness failed.
resultAlways last: the outcome (completed, failed, or interrupted), exit_code, this run's usage, and the skills the agent loaded.

The answer is only in the answer event. To extract it with jq:

terminal
sh
pandra run github.com/acme/reviewer@v1.2.0 --harness claude-code \
    --prompt "Review PR 12." --json \
    | jq -r 'select(.type == "answer") | .text'

To continue the conversation later, keep the session_id of the session event:

terminal
sh
pandra resume 9f2c4e1a7b3d5c6e8f90a1b2c3d4e5f6 \
    --prompt "I fixed the findings. Review the changes again." --json

A stream without a result event ended abnormally: treat the run as incomplete. Pandra never resends a prompt on its own.

--events activity adds activity events with the agent's messages, its tool calls without their inputs and outputs, and its plan updates. The session's log has the inputs and outputs.

Detached runs in JSON ​

With --detach, run and resume print one document instead of the event stream:

terminal
sh
pandra run github.com/acme/reviewer@v1.2.0 --detach --json \
    --prompt "Review PR 12."
text
{"schema_version":"1.0","session":{"session_id":"b64e3afdb4e144db9dfb089787054c9d","name":null,"agent":"github.com/acme/reviewer","package_digest":"sha256:2a0123b71802b62e556e0505031759344967fbe620a2ecd5d7f2f756f8901c7a","harness":"claude-code","workspace":"/home/me/project"}}

pandra session wait --json prints one document once the run has ended or the timeout has ended the wait:

terminal
sh
pandra session wait --json b64e3afdb4e144db9dfb089787054c9d
text
{"schema_version":"1.0","session_id":"b64e3afdb4e144db9dfb089787054c9d","run_id":"d065f8c415f24b219ddd2505a24b7e7a","running":false,"outcome":"completed","exit_code":0,"usage":{"input_tokens":10,"output_tokens":5,"cached_input_tokens":0,"cost_usd":0.000035},"skills":{"loaded":["review"],"preloaded":[],"not_loaded":["pandra","simplify"],"loaded_in_run":["review"]},"answer":{"text":"No blocking problems in PR 12.","data":null},"error":null,"warnings":[]}

Its fields are those of the run's result, answer, and error events. When the timeout ended the wait, running is true and outcome is null. pandra session send --json prints the session_id, name, and run_id of the run that took the message.

Session logs in JSON ​

pandra logs SESSION --json prints what a session's agent did (see what an agent did) as JSON lines: a version line, then for each run a run line followed by an activity line per entry. To show the failed cargo test of a review in full:

terminal
sh
pandra logs review1 --item 3 --json
text
{"type":"version","schema_version":"1.0"}
{"type":"run","run_id":"ffbd958aeb0c48f7b548a600b1a4f956","mode":"headless","started_at":"2026-11-17T15:07:14Z","ended_at":"2026-11-17T15:07:14Z","outcome":"completed","usage":{"input_tokens":10,"output_tokens":5,"cached_input_tokens":0,"cost_usd":0.0012}}
{"type":"activity","update":"tool_call","text":null,"tool_call_id":"toolu_01","title":"Bash: cargo test","kind":"execute","status":"failed","entries":null,"seq":3,"recorded_at":"2026-11-17T15:07:14Z","error":"    auth::compare\ntest result: FAILED. 11 passed; 1 failed; 0 ignored\nerror: test failed, to rerun pass `--lib`","input":{"command":"cargo test","description":"Run the tests"},"output":"running 12 tests\ntest auth::compare ... FAILED\n\nfailures:\n    auth::compare\n\ntest result: FAILED. 11 passed; 1 failed; 0 ignored\n\nerror: test failed, to rerun pass `--lib`","thought":null}

seq is the number --item takes, and error holds the last lines of a failed tool call's output. input, output, and thought are null unless the entry is shown in full, with --item, --failed, or --full. A prompt is an activity line whose update is user_message.

Structured answers ​

--output-schema FILE asks the agent for a final answer that matches a JSON Schema, for scripts that process the answer. With this schema in findings.schema.json:

json
{
  "type": "object",
  "properties": {
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "file": {"type": "string"},
          "line": {"type": "integer"},
          "severity": {"type": "string"},
          "message": {"type": "string"}
        },
        "required": ["file", "line", "severity", "message"],
        "additionalProperties": false
      }
    }
  },
  "required": ["findings"],
  "additionalProperties": false
}
terminal
sh
pandra run github.com/acme/reviewer@v1.2.0 --prompt "Review PR 12." \
    --output-schema findings.schema.json
text
{"findings":[{"file":"src/auth.rs","line":42,"message":"Token compared with ==","severity":"high"}]}

With --json, the answer is in the answer event's data. An answer that does not match fails the run with output_schema_mismatch and exit code 1, and Pandra never reruns the agent, because the run may have had side effects:

text
error: the final answer does not match the output schema: at "/findings/0": missing properties 'message'; at "/findings/0/line": want integer, but got string
  • On Codex, the schema must also meet OpenAI's strict mode, as this one does: an object at the root, additionalProperties: false on every object, and every property in required. Another schema fails before the run starts, with output_schema_unsupported.
  • --output-schema works with headless run and resume. --tui, --acp, and Pi reject it.

Quieter output ​

  • -q, --quiet prints only the answer, errors, and for list commands the identifiers (pandra ps -q). JSON output is unchanged.
  • --no-progress, or PANDRA_NO_PROGRESS, turns off progress on stderr.
  • --color never, or NO_COLOR, turns off color.
  • --offline, or PANDRA_OFFLINE, fetches nothing Pandra manages, so anything missing fails early.
  • -v, --verbose adds diagnostics on stderr; repeat it for more.

Errors ​

A failing command prints a message, the problems it found, and the commands that fix them, in order. With --json, it prints one document with an error object, here formatted on several lines:

terminal
sh
pandra sync ghcr.io/acme/notifier:1.0.0 --json
json
{
  "schema_version": "1.0",
  "error": {
    "code": "preflight_failed",
    "origin": "pandra",
    "message": "ghcr.io/acme/notifier@sha256:9f2c1a7b3d5c4e6f8a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f has not been approved",
    "issues": [
      {"code": "package_not_approved", "message": "ghcr.io/acme/notifier@sha256:9f2c1a7b3d5c4e6f8a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f has not been approved", "details": {"agent": "ghcr.io/acme/notifier", "package_digest": "sha256:9f2c1a7b3d5c4e6f8a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f"}}
    ],
    "details": null,
    "remediation": [
      {"command": "pandra agent inspect ghcr.io/acme/notifier@sha256:9f2c1a7b3d5c4e6f8a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f", "needs_user": false, "description": "show what the agent contains"},
      {"command": "pandra agent trust ghcr.io/acme/notifier@sha256:9f2c1a7b3d5c4e6f8a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f", "needs_user": true, "description": "approve the agent, and later revisions that keep its MCP servers and pre-approve no new tool"}
    ]
  }
}
  • code is stable and never reused for another meaning. origin is pandra or harness.
  • issues lists every problem found, and remediation lists the steps in order.
  • needs_user marks a step an AI agent must not take on its own, such as approving a package or allowing a server.
  • command is null for a step that is not one command, such as installing a program; its description says what to do.

pandra agent remove, pandra session remove, pandra quest remove, and pandra session prune remove each item they can. When one fails, the error's details.removed lists what the command reports as removed, each entry as in the removed list of its document, so a script still learns what is gone. For agent remove, it includes a removal whose approval Pandra then could not remove, and each entry's approval_removed holds the approval that removing it took, as pandra agent untrust --json reports it, or null.

run, resume, and quest run report a failure inside their event stream instead, as an error event with the same fields, followed by the result event:

terminal
sh
pandra resume nosuch --prompt "Continue." --json
text
{"type":"version","schema_version":"1.0"}
{"type":"error","code":"session_not_found","origin":"pandra","message":"no session matches nosuch","issues":[],"details":null,"remediation":[{"command":"pandra ps -a","needs_user":false,"description":"list every session"}]}
{"type":"result","session_id":null,"outcome":"failed","exit_code":1,"usage":{"input_tokens":null,"output_tokens":null,"cached_input_tokens":null,"cost_usd":null},"skills":null}

A usage error is the exception: those commands report it as an error document, so their callers handle both forms. Put --json before the other options, since after an option the command does not have, the usage error is plain text.

Exit codes ​

A command exits 0 on success, 1 on a Pandra error, 2 on a usage error, and 130 when it was interrupted or you answered no to a question it needed. A failed turn of the harness exits with the harness's code. Exit codes and errors lists every exit code, error code, and issue code.

Released under the Apache License 2.0