Repository navigation
Workers
A worker is a separate pi process started in RPC mode. It has its own context
window, tools, model and session, works in the coordinator's directory, and
reports back exactly once per run (or once per follow-up).
starting → running → (question ↔ running)* → settled
└→ stopped | failed | timeout | lost
| Status | Meaning |
|---|---|
starting |
Process spawned, prompt not yet accepted. |
running |
Working; events streaming into the log. |
question |
Blocked on orchestra_ask until answered. |
settled |
agent_settled observed; report captured. |
stopped |
Aborted by worker_stop, /orchestra stop, or shutdown. |
failed |
Process exited without settling, or the prompt was rejected. |
timeout |
timeoutMs expired; the process was stopped. |
orphaned |
A coordinator restart found the process still alive (⚡): stoppable by pid, resumable. |
lost |
State said running, and the process is gone. |
-
--append-system-prompt .pi/orchestra/prompts/<dispatch>.mdwhen the agent defines a system prompt. - A preamble with its dispatch id, run name, working directory and the task.
- Rules: work autonomously, ask via
orchestra_askfor decisions that belong to the coordinator, never delegate, and end with a short report of changes, evidence and open items. - The tools of its agent (plus
orchestra_ask), or every built-in tool when the agent has notoolslist.
---
name: reviewer
description: Read-only code review
tools: read, grep, find, ls
model: claude-sonnet-4-5
provider: anthropic
thinking: high
---
You review code and report findings ordered by severity. You do not edit files.-
~/.pi/agent/agents/*.md— user agents -
.pi/agents/*.md— project agents (override user agents with the same name)
name defaults to the file name. description, tools, model, provider and thinking
are optional.
A spec must be self-contained — the worker cannot see the coordinator's conversation:
- the target (paths, symbols, endpoints)
- the change to make
- constraints (style, dependencies, what not to touch)
- what the worker may edit
- the evidence that proves it is done (a command, a test, a diff)
- whether a non-zero exit is a failure or the deliverable
worker: orchestra_ask question="Migrate or keep the old table?"
coordinator (wake): ? Worker dispatch_ab12 is blocked on a question
coordinator: orchestra_answer questionId=q_9f3c1a2b answer="Keep it, add a view."
worker: resumes with the answer
The question is a file in .pi/orchestra/mail/<dispatch>/. The coordinator polls
once a second, records the gate in state, and messages the model. orchestra_wait
returns as soon as a gate appears, so a blocked worker never deadlocks a wait.
- Running worker:
orchestra_sendqueues a steering message, delivered after the current assistant turn's tool calls. - Settled worker with
keepOpen: true: the message starts a follow-up turn in the same context; the task reopens and the worker reports again.
| Need | Call | Behaviour |
|---|---|---|
| Continue the same worker | orchestra_send |
Only while it is alive (keepOpen: true). Same process, same context. |
| Reopen an ended one | worker_resume dispatch=<id> |
New dispatch on the same pi session (sessionMode: "session" required), linked with resumedFrom; the prompt is just the continuation. |
| Start clean after a failure | worker_start retryOf=<id> |
New dispatch, fresh context, but the spec/agent/tools/model are reused and the prompt leads with the previous status, error, last tool and report. |
A resume of a task that was already done puts the task back to running, so
readiness and the widget stay honest.
retries closes the loop: when a worker ends failed/timeout (not a
deliberate stop, not a resumed session), the coordinator queues a repair
dispatch after retryBackoffMs (doubling per attempt, capped at 5 minutes), up
to the attempt budget, and reports when the next attempt starts.
-
maxConcurrencyrunning workers (default 4). -
timeoutMsper worker (default 15 minutes) — a hard kill, measured from spawn intimeoutMode: "total"(default), or from the worker's last event in"idle".0disables it;worker_start timeoutMs=overrides it per dispatch. -
budgetMsPerWorker— a soft deadline: the worker is asked to wrap up, then stopped afterbudgetGraceMs. -
budgetUsdPerWorker/budgetUsdPerRun— cost ceilings checked on every event. -
stallMs— a worker with no events for this long is flaggedstalled(⚠ stalled 12m), and stopped instead whenstallAction: "abort". - Output kept for the coordinator: the dispatch report is capped at 4000 characters; the full log stays on disk.
A worker is its own process, so the coordinator does not need to block:
-
orchestra action=worker_start …returns as soon as the process is up. - End the turn. You are woken with the worker's report (and usage) when it settles, and immediately when it asks a question.
- Keep using the session — or another session — while it runs. State lives in
.pi/orchestra/, so a restart or/orchestra browsepicks the run up.
orchestra_wait timeoutMs=… is for the cases where the next step needs the result:
it returns on settle, on a question, or on its own timeout, and replaces polling.
For long jobs, see Configuration — timeoutMode: "idle" or
timeoutMs: 0 keeps a busy worker alive for as long as it needs.