master-orchestrator0.6.0
Pi package that turns pi into an orchestrator of other coding agents: delegation, debate and planning
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
master-orchestrator
A pi package that turns pi into an orchestrator of other coding agents. Pi delegates assignments to Codex, Claude Code, OpenCode, pi, oh-my-pi, Antigravity, Grok Build and DeepSeek Harness, moderates debates between them, and plans and executes multi-step work with per-block review.
Read this first: what the workers can do
Every worker runs with unattended full access. Each agent is started with all of its tools, no approval prompts and no sandbox, in both analyze and implement mode. A worker can read, write and execute anything your user account can, inside the workspace and outside it, and it can reach the network.
The package adds no restriction of its own. What it does instead:
- It states each assignment precisely (mode, editable scope, Git policy, no further delegation).
- It diffs the workspace before and after every run and reports what actually changed, including changes an
analyzerun should not have made and changes outside the scope of animplementrun. - It never reverts, resets, stashes or deletes to undo a worker's changes. It reports, and the decision stays with you.
- It bounds every run with a timeout, lets you cancel it, and allows one writer per workspace.
- It stops recursion: a worker that loads this package registers nothing.
- A debate or a plan starts only from a command you type, and shows its maximum number of agent runs before it starts.
Install it only where you would run those agents unattended yourself.
Install
pi install npm:master-orchestrator
Linux and macOS. Node 22.18 or newer (the version pi needs). The agents themselves are not installed by this package: install and log in to the ones you want, then run /orchestrator doctor.
Use
Pipeline
The three flows stay separate, and a result goes from one to the next only when you name it with --from. No command chains the stages.
[0 Prepare] → [1 Explore] → [2 Decide] → [3 Plan] → [4 Execute] → [5 Close]
doctor/init /delegate /debate /plan blocks + report
(optional) (optional) + preview plan_verdict
└─ --from run ─┴─ --from debate ─► brief saved with the plan
small task: /delegate --implement, and that is all
failure in 4: pause → /plan resume · at any time: /orchestrator status
| Stage | Moves on when |
|---|---|
| 0 Prepare | The configuration is valid; at least one agent can run; the roles of the flow you want are configured |
| 1 Explore (optional) | The run ended with a final answer; you looked at any unexpected changes |
| 2 Decide (optional) | The debate has a terminal status other than failed and at least one position; the synthesis is recorded, or pending with the positions as the source |
| 3 Plan | The plan validates, names no step profile that does not exist, and you confirmed after seeing the preview |
| 4 Execute | Git, a clean tree (or your confirmation) and a free write lock; every block ends accepted or skipped; a failure pauses and goes on with /plan resume |
| 5 Close | The status is completed or completed_with_skips; the report was delivered; the artifacts are back to normal retention |
A small task needs none of this: /delegate <profile> --implement <task> and it is done. /orchestrator status shows, at any time, where things stand and the next command. Each flow also ends with its next step: after a /delegate run, the --from run:<id> commands; after a debate, /plan --from debate:<id>; after a plan paused or was kept as a draft, /plan resume <id>.
From the model: delegate_task
Pi's model can call delegate_task on its own:
| Parameter | Notes |
|---|---|
task |
Self-contained assignment; the worker sees none of the conversation |
profile |
Profile name or agent id (codex, claude, ...) |
role |
Alternative to profile: the role's fallback chain |
mode |
analyze (default) or implement |
scope |
Editable paths and globs for implement |
followUpRunId |
Continue the session of an earlier run |
The model has no tool that starts a debate or a plan. Its guidelines tell it to suggest /debate or /plan to you when a decision needs several opinions or the work needs a reviewed plan, and not to imitate either with a series of delegate_task calls.
The result contains the worker's final answer, the files it changed, any unexpected or out-of-scope changes, denied actions, usage and the path of the run's artifacts. Parallel analyze calls run concurrently, bounded by defaults.maxParallel. With approval.implementFromTool: "ask", model-initiated implement runs need your confirmation.
Commands
| Command | Purpose |
|---|---|
/delegate [profile] [--implement] [--role r] [--scope a,b] [--follow-up runId] [--from ref] [--] <task> |
One assignment. Without arguments: pickers for profile and mode, an editor for the task |
/debate <question> |
Debate between the profiles of the debater role; pi moderates and writes the synthesis |
/debate --from <ref> [question] |
Debate from the result of a run or of an earlier debate. /debate -- <question> takes the text as it is |
/plan <goal> |
Planning: draft, critique, revision, your approval, then execution block by block |
/plan --from <ref> [goal] |
Plan from the result of a debate or of a run. <ref> is the id, or debate:<id> or run:<id> |
/plan -- <goal> |
Plan the text as it is, also when it starts with status, abort, resume or -- |
/plan resume [id], /plan status [id], /plan abort [id] |
Control a plan |
/orchestrator, /orchestrator status |
Where things stand: the write lock, what is active in this session, the plans with their progress, the recent debates and runs, and the next command |
/orchestrator doctor |
Installed agents, versions against the tested range, auth status, models, configuration |
/orchestrator init |
Write a starter configuration from the detected agents |
/orchestrator config |
Edit profiles and roles interactively |
/orchestrator runs |
Active and recent runs with their artifact paths, and the recent debates with their ids |
/orchestrator cancel [runId|all] |
Cancel runs or the active workflow |
/delegate has the capabilities of the tool. The first word is the profile when it names one; --role <role> uses the role's fallback chain instead. --implement (or -i) makes it an implement run and --scope <a,b> gives its editable paths. --follow-up <runId> continues the session of an earlier run, on that run's profile. --from <ref> puts the result of a debate or a run ahead of the task in the assignment. The options come before the task, in any order, and -- ends them: /delegate -- pi is slow does not read pi as a profile.
Commands return immediately and work in the background; results arrive as messages in the session. A message that only informs, such as the result of /delegate, does not interrupt a turn in progress: it is added after the turn.
Status
/orchestrator status (or /orchestrator alone) only reads. It lists the holder of the workspace write lock, the runs and workflows active in this session, the plans, the recent debates and the recent runs, marks what this session started, and ends with one suggested command. A plan is shown as:
- running in this session;
- executing elsewhere, with the process id, pi session and start time of the session that runs it: it can be resumed or aborted only there, so nothing is suggested for it;
- interrupted, when its state says
executingand no live session holds the lock for it; - paused, approved or draft;
- state file missing or unreadable, with
/plan abort <id>as the way to release its artifacts; - finished.
An open plan that has been stopped for longer than defaults.artifactRetentionDays is highlighted, in the panel and at session start: its artifacts are kept until it completes or is aborted, and the line names both commands.
Debate
Each participant answers the brief independently, then sees the others' answers (anonymized by default) and keeps or revises its position, for up to debate.maxRounds rounds or until positions converge. debate.minParticipants is the minimum to start: the debate does not begin with fewer debaters that can run. Once it runs, a participant that fails is dropped and the debate continues while two participants remain active. With fewer than two there are two outcomes: when at least one position was completed, the debate ends as partial and pi writes the synthesis from what exists; when nobody produced a position, it ends failed, with an error message and no synthesis turn. The full record is written to the run artifacts; pi writes the synthesis. The synthesis is saved in the record (debate.json, debate.md) when pi's answer can be attributed to the debate from the order of the messages of the turn; otherwise it stays pending there and the positions remain the source. It stays pending, for example, when several requests are answered by one turn (pi's follow-up mode all) or when another message comes between the request and its answer.
Passing a result on
A flow can start from the result of an earlier one, named by its id: /plan --from <id>, /debate --from <id> and /delegate --from <id>. The briefs of debates and plans are also framed with the recent conversation, which includes the results this package posted in the session (a /delegate result, a plan's report), each cut to a few kilobytes. Nothing is passed implicitly: you name the result, and the brief you review shows where it came from in an ## Origin section. The reference has a canonical form, debate:<id> or run:<id>, which is what is saved (in the plan's state, or the debate's record) and shown; nothing else of the origin is saved outside the brief. /orchestrator runs lists the ids.
- A debate can be an origin once it ended with at least one position: converged, at the round limit, partial, cancelled or stopped. Its positions, and its synthesis when recorded, frame the brief, and the
## Originsection says whether the synthesis was recorded and who is missing from a partial debate. A failed debate, one without a position and one whose record does not say it ended are refused. - A run can be an origin once it ended and left a final answer. Its report and its mechanical summary (the files it changed, unexpected and out-of-scope changes) frame the brief, and the
## Originsection shows a status other thancompletedand any unexpected changes. A run without a final answer and one that has not ended are refused. - An id without a kind is looked up among both. If a debate and a run share it, the command asks you to say which:
debate:<id>orrun:<id>.
status, abort and resume are subcommands of /plan only alone or followed by a plan id. /plan status report page does neither thing and tells you both ways out: /plan -- status report page to plan it, /plan status [id] for the subcommand.
Planning and execution
A planner drafts a plan document; critics review it; the planner revises (up to
planning.maxRevisionstimes).You approve, edit, ask for a revision, keep it as a draft, or discard it. Approving opens a confirmation that shows what would start: the profiles of the roles, the steps with a profile of their own, the state of Git, the files the steps may change, the holder of the workspace write lock and the execution settings. A step that names a profile that does not exist blocks the approval; a held lock or a dirty tree is a warning. The plan lives in
<project>/.pi/master-orchestrator/plans/<id>.md, with its state in<id>.state.jsonin the same directory; both are meant to be versioned.Execution runs the steps of each block with the
implementerrole. Then the block is settled in a fixed number of runs:- The
reviewerreviews the block's whole change set, once. A correction never leads to another review. - The implementer answers every finding in its own session:
fixed(it makes the fix in the same run),rejectedordeferred, with a reason. - When a blocking finding was fixed, the reviewer confirms the fix against the diff of that correction alone, and may only add a regression the correction introduced.
- Pi's model gives the verdict with the
plan_verdicttool (accepted,needs_fix,blocked) and rules on each blocking finding that is still unsettled:fixordismiss.
needs_fixsends back only the findings ruledfix, plus the verdict's feedback, at mostmaxFixAttemptstimes per block; after that the plan pauses and you decide. The reviewer does not gate a block: what stops one is a failing validation or a finding pi's model ruledfixthat is still not fixed. Findings that end rejected, deferred or dismissed are listed in the final report.- The
A failed or interrupted step pauses the plan and offers retry, skip, edit or abort.
/plan resumecontinues after a restart, from the first step that is not done; a draft goes on at the phase it had reached (critique, revision or approval), without repeating a revision that was already written. The brief you reviewed is saved with the plan's state, with absolute paths rewritten (workspace paths as./, others as placeholders), so both files can be versioned./plan abort [id]is final in any phase: nothing written afterwards brings the plan back, and it is refused while another pi session executes the plan.
With planning.execution.commit: "per-block" each accepted block is committed with its title as the message. The default is none: committing is your decision.
Configuration
Files, later ones override earlier ones (objects merge key by key, arrays replace):
- Built-in defaults.
- User:
~/.pi/agent/master-orchestrator.json. - Project:
<project>/.pi/master-orchestrator.json, only when the pi session trusts the project.
A project file cannot loosen approval and cannot set agents.*.bin, agents.*.env, agents.*.extraArgs or profiles.*.options: a repository must not choose which executable runs or with which flags. An invalid file disables delegation and workflows and reports the exact path and error; it never falls back to defaults silently. Comments (//, /* */) and trailing commas are accepted.
{
"agents": {
"codex": {
"enabled": true, // default: true when detected
"bin": "codex", // executable name or absolute path
"env": {}, // environment additions for every run
"extraArgs": [],
"allowUntestedVersion": true // run with a warning outside testedVersions
},
"grok": { "persistTrust": false } // pass --trust, which persists the grant in grok's configuration
},
"profiles": {
"codex-deep": { "agent": "codex", "model": "<model id>", "effort": "high" },
"claude-fast": { "agent": "claude", "model": "<model id>", "timeoutMinutes": 15 },
"dsh-route": { "agent": "dsh", "options": { "patchFile": "/abs/path/route.yml" } }
},
"roles": {
"planner": ["claude-fast", "codex-deep"], // ordered fallback chain
"critic": ["codex-deep"], // every listed profile takes part
"implementer": ["codex-deep", "claude-fast"], // ordered fallback chain
"reviewer": ["claude-fast"], // ordered fallback chain
"debater": ["codex-deep", "claude-fast"] // every listed profile takes part
},
"defaults": { "timeoutMinutes": 30, "maxParallel": 4, "artifactRetentionDays": 14 },
"approval": {
"implementFromTool": "auto", // "auto" | "ask"
"workflowStart": "ask" // "ask" | "auto": confirmation before a debate or plan
},
"debate": { "maxRounds": 2, "anonymize": true, "minParticipants": 2 },
"planning": {
"maxRevisions": 1,
"execution": {
"mode": "auto", // "auto": stop on failure | "block": confirm each block
"maxFixAttempts": 1, // extra corrections per block, after the response
"review": "per-block", // "per-block" | "none"
"commit": "none", // "none" | "per-block" (needs requireCleanTree)
"requireCleanTree": true
}
},
"prompts": { "dir": null } // directory with template overrides (<name>.md)
}
Bounds: timeoutMinutes 1–720, maxParallel 1–16, artifactRetentionDays 1–365, debate.maxRounds 0–5, debate.minParticipants 2–8, planning.maxRevisions 0–3, maxFixAttempts 0–5.
Every detected agent also has an implicit profile named after it, with no model or effort, so the agent uses its own defaults: a fresh install delegates with zero configuration. Roles have no built-in mapping; a workflow that needs an unconfigured role asks you to pick profiles and offers to save the choice. Models and effort levels are passed as configured, never invented.
Supported agents
| Agent | Binary | Tested versions | Full-access invocation | Live-checked (2026-11-25) |
|---|---|---|---|---|
| Codex | codex |
>=0.163.0 <0.200.0 | -a never --sandbox danger-full-access |
0.172.0: analyze, implement, follow-up, cancel, timeout, denial, auth failure, quota¹ |
| Claude Code | claude |
>=2.1.305 <2.2.0 | --permission-mode bypassPermissions, sandbox disabled through --settings |
2.1.328: analyze, implement, follow-up, cancel, timeout, denial, auth failure, quota¹ |
| OpenCode | opencode |
>=2.1.3 <2.4.0 | --auto |
2.3.0: analyze, implement, follow-up, cancel, timeout, denial, auth failure, quota¹ |
| pi | pi |
>=1.4.0 <1.7.0 | none needed | 1.6.1: analyze, implement, follow-up, cancel, timeout, denial, auth failure, quota¹ |
| oh-my-pi | omp |
>=18.11.1 <20.0.0 | --auto-approve (a per-run overlay also turns off auto-resume) |
19.1.1: analyze, implement, follow-up, cancel, timeout, denial, auth failure, quota¹ |
| Antigravity | agy |
>=1.4.4 <1.6.0 | --dangerously-skip-permissions |
1.5.17: analyze, implement, follow-up, cancel, timeout, denial, auth failure, quota¹ |
| Grok Build | grok |
>=1.0.62 <1.1.0 | --always-approve, GROK_SANDBOX unset |
1.0.77: analyze, implement, follow-up, cancel, timeout, denial, auth failure, quota¹ |
| DeepSeek Harness | dsh |
>=0.2.1-rc.3 <0.3.0-0 | DSH_PERMISSION_MODE=danger-full-access |
0.2.2-rc.3: analyze, implement, follow-up, cancel, timeout, auth failure, quota¹ |
¹ Against a local provider stand-in (test/live/provider-mock.ts) that answers every model call with that provider's own quota error: the agent CLI runs for real and only the provider is simulated, since a real account cannot be exhausted on demand. Each CLI reaches the stand-in through per-run flags, environment and scratch directories (test/live/provider-setups.ts); your own agent configuration is never changed.
Every adapter is stable. For all eight, real runs of the version above established what the specification's verification pass asks: the prompt channel, the events, session and resume, the full-access flags, the stop signal, the exit codes, and how a denial, a timeout, an auth failure and a quota failure appear. Quota failures were seen against the stand-in. At a timeout, every agent stopped cleanly on its stop signal, and the run reports timeout even when the agent then exits 0 (Claude Code and DeepSeek Harness do). The recorded runs are in test/fixtures/<agent>/live-*.json, and /orchestrator doctor shows what was checked. Outside the tested range an agent still runs, with a warning, unless allowUntestedVersion is false.
DeepSeek Harness runs its headless profile, which has no model flag. A provider declared only in another dsh profile is not visible there: put its llm-pi-ai row in a patch file, point the profile's options.patchFile at it, and set model to <provider>/<model>.
What still applies inside a run is whatever you configured in the agent itself: deny rules, policies and hooks. A run can end on a denial, and the result reports it. A refused tool call that the agent works around leaves the run completed, with the call in deniedActions. Observed live per agent:
- Claude Code (
--disallowedTools), Grok Build (--deny) and OpenCode (adenypermission) report the refusal in their event stream. - Antigravity reports a
permissions.denyrule as a failed tool step and goes on with the turn. - Codex leaves no trace of an execpolicy
forbiddenrule in its JSON stream; the refusal is read from its stderr log. - pi and oh-my-pi report a call blocked by an extension's
tool_callhandler as an ordinary tool error whose text is the handler's reason. It is recognized as a denial only when that text says the call was blocked, as pi's and oh-my-pi's default texts ("Tool execution was blocked", "Tool execution was blocked by an extension") do. - DeepSeek Harness, which runs with
DSH_PERMISSION_MODE=danger-full-access, has nothing in 0.2.2-rc.3 that can refuse a call: its hooks and auto-review plugins are experimental packages that the npm release does not ship.
When the pi session trusts the project, adapters pass their agent's per-run trust flag so it loads project rules (--approve for pi). Grok Build's --trust persists the grant in its configuration and is passed only with agents.grok.persistTrust: true.
Data handling
Each run writes its artifacts under ~/.pi/agent/master-orchestrator/runs/<workspace hash>/<run id>/: the assignment, the agent's event stream, stderr, the final answer and a meta.json. The meta.json holds the run's mechanical summary: whether it left a final answer, its duration, the files it changed, unexpected and out-of-scope changes, departures from the Git policy, denied actions, the scope and a title of the assignment. That is what a later --from run:<id> reads. They can contain source code and anything the worker printed. They stay on your machine and nothing is uploaded by this package. Directories older than defaults.artifactRetentionDays are removed at session start, and only those of the workspace the session opens in: the artifacts of a workspace are cleaned up only when a session is opened in it. The artifacts of a plan that is not finished (draft, approved, executing or paused) are kept whatever their age, until the plan completes or is aborted: its workflow directory, the runs its state cites and its planner and critic runs. /plan abort <id> is the explicit way to release them, also for a plan whose state file cannot be read; that plan is then left as it is and only its artifacts are released. What each agent sends to its own provider is governed by that agent and its configuration.
No adapter reads credential files or prints environment values; diagnostics name the missing variable or the login command.
Reference material
.agents/skills/delegate-* and openbot/ are reference material kept in the repository. They are not part of the published package (files in package.json lists src, README.md, CHANGELOG.md and LICENSE), they do not follow the adapters' policy of unattended full access, and they do not mirror the contracts described here.
Development
npm install
npm test # parser, invocation, engine, workflow and extension tests; no tokens spent
npm run check # tsc --noEmit
MO_LIVE_AGENTS=codex,claude node --test --experimental-strip-types test/live/smoke.test.ts # spends tokens
The live tests take per-agent overrides: MO_LIVE_MODEL_<AGENT>, MO_LIVE_OPTIONS_<AGENT> (profile options as JSON), MO_LIVE_ENV_<AGENT> (agent env as JSON), MO_LIVE_TRUSTED=1 to run as a trusted project, MO_LIVE_TIMEOUT=1 to add a timeout test that takes over a minute per agent, MO_LIVE_QUOTA=1 and MO_LIVE_AUTH=1 to add quota and auth failure tests against the provider stand-in, MO_LIVE_INVALID_KEY=1 to add an auth failure test that sends an invalid key to the real provider (OpenCode, Antigravity; no tokens spent by any of them), and MO_LIVE_DENY_<AGENT> to add a denial test: a JSON object with the extraArgs, env or workspace files that set up the agent's own deny rule for sleep.
The specification is in docs/SPEC.md.
License
MIT