Running in the background
--detach starts a run in the background: a headless run that keeps going after the command returns, as docker run -d starts a container. The command prints the run's session ID on stdout, and pandra session wait later waits for the run to end and prints the agent's answer:
$ id=$(pandra run github.com/acme/reviewer@v1.2.0 --detach --prompt "Review PR 12.")
✓ Prepared · 0.0s
Session: 5895c85ecd07 (reviewer)
$ pandra session wait "$id" > review.md
Skills not loaded: pandrapandra resume and pandra guild run take --detach too.
Start a run in the background
Until the run has its session, the command works as without --detach: it fetches and builds the agent, asks on a terminal what any run asks, such as whether you approve a remote agent, and fails with the same error (starting a run). Once the run has its session, the command prints the session's full ID and returns. --detach cannot be combined with --tui, --acp, --events, or --rm; remove the session with pandra session remove "$id" once you have read the answer.
To continue a session in the background, resume it with --detach:
pandra resume pr-12 --detach --prompt "Check the new commits."Wait for the answer
pandra session wait SESSION waits until the run has ended, prints the answer on stdout, and on stderr the run's warnings, its error, and the fields that name the skills the agent loaded. It exits as the run exited (exit codes). It waits for any run, not only a detached one, though a TUI or ACP run has no answer to print. For a session that no run is working on, wait reports the session's last run at once. --timeout ends the wait after a duration, such as 90s, 10m, or 2h, while the run keeps going:
$ pandra session wait --timeout 1m "$id" > review.md
run 610161220fae41da8cf7c768d8bfba82 of session 5895c85ecd07 is still runningCtrl-C ends the wait, not the run. To wait for several runs, start one wait for each, each into its own file:
pandra session wait "$a" > a.md & pandra session wait "$b" > b.md & waitSend a message to a run
To tell a running agent something, such as a correction to its task, send it a message. The command returns once the harness has taken the message, and pandra session wait then waits for the answer:
$ pandra session send pr-12 --prompt "Use the staging database, not production."
Sent a message to session 3fd5c56315a34ec2878bde4d71dbcf3d (pr-12)
$ pandra session wait pr-12 > review.md
Skills not loaded: pandraEvery headless run takes messages, detached or not. A message to a TUI run or an ACP endpoint fails the command with session_not_headless: in the TUI, type into the harness's interface instead. The agent reads the message at its next tool boundary, such as when the command it is running ends, and when it ends its turn first, the run can start another turn for it. wait then prints the answer of that last turn.
A message can go unread, such as when the turn fails or is stopped before the agent reads it. The run then says so in a warning, which wait prints too; resume the session with the message to give it to the agent:
$ pandra session wait pr-13
warning: 1 message(s) the harness took were not read, because the turn ended as interrupted; resume the session with them
interrupted, session f7841fb3278b
Skills not loaded: pandraA session that no run works on takes no message, and neither does a run that is stopping or whose last turn has ended. The error then gives the step that resumes the session with the message:
$ pandra session send pr-12 --prompt "Also check the migrations."
error: session 3fd5c56315a34ec2878bde4d71dbcf3d takes no message: no run works on it, or its run is stopping or has ended its last turn
To resume the session with the message, on standard input:
pandra resume 3fd5c56315a34ec2878bde4d71dbcf3d --prompt -When the run cannot take the message within 60 seconds, such as while 16 messages already wait, the command fails with send_timeout and sending it again is safe. When it fails with send_unconfirmed, the agent may still read the message, so check with pandra logs before you send it again.
Follow or stop a run
pandra ps lists the session of a detached run as creating until its harness has started the conversation, then as active until the run ends, and pandra logs SESSION --follow shows what the agent is doing (see what an agent did). pandra session stop SESSION interrupts the run as Ctrl-C interrupts a foreground run, and returns once the run has ended:
$ pandra session stop "$id"
Stopped session 5895c85ecd074c3bbeb33ba7b93a45adThe run ends as interrupted, and pandra resume can continue the session.
What keeps running
A detached run acts with your credentials, permissions, and tools, and uses tokens, until it ends or you stop it. Closing the terminal does not stop it. A message the agent has not read can keep it going for another turn, and so can work that the agent started in the background on a harness that has it (Claude Code). In CI, wait for a run in the job that started it, since a CI runner can end a job's processes when the job ends.
The run writes what it would have printed on stderr to ~/.local/share/pandra/sessions/SESSION_ID/runs/RUN_ID/stderr.log (or under $XDG_DATA_HOME/pandra when that variable is an absolute path), which only you can read and which goes with the session. It holds no secret value Pandra resolved, but the harness's own output can hold anything the agent saw.
With --json, run --detach, session send, and session wait each print one document (detached runs in JSON).