pi-orchestra

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).

Lifecycle

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.

What a worker receives

  1. --append-system-prompt .pi/orchestra/prompts/<dispatch>.md when the agent defines a system prompt.
  2. A preamble with its dispatch id, run name, working directory and the task.
  3. Rules: work autonomously, ask via orchestra_ask for decisions that belong to the coordinator, never delegate, and end with a short report of changes, evidence and open items.
  4. The tools of its agent (plus orchestra_ask), or every built-in tool when the agent has no tools list.

Agents

---
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.

name defaults to the file name. description, tools, model, provider and thinking are optional.

Writing a task spec

A spec must be self-contained — the worker cannot see the coordinator's conversation:

Questions

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.

Steering

Resume and repair

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.

Limits

Running in the background

A worker is its own process, so the coordinator does not need to block:

  1. orchestra action=worker_start … returns as soon as the process is up.
  2. End the turn. You are woken with the worker's report (and usage) when it settles, and immediately when it asks a question.
  3. Keep using the session — or another session — while it runs. State lives in .pi/orchestra/, so a restart or /orchestra browse picks 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.