master-orchestrator

Pi package that turns pi into an orchestrator of other coding agents: delegation, debate and planning

Packages

Package details

extension

Install master-orchestrator from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:master-orchestrator
Package
master-orchestrator
Version
0.5.0
Published
Nov 26, 2026
Downloads
669/mo · 669/wk
Author
quantmind-br
License
MIT
Types
extension
Size
422.2 KB
Dependencies
2 dependencies · 4 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ],
  "changelogPath": "./CHANGELOG.md"
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

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 analyze run should not have made and changes outside the scope of an implement run.
  • 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

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 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] <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
/plan <goal> Planning: draft, critique, revision, your approval, then execution block by block
/plan resume [id], /plan status, /plan abort [id] Control a plan
/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
/orchestrator cancel [runId|all] Cancel runs or the active workflow

Commands return immediately and work in the background; results arrive as messages in the session.

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. A participant that fails is dropped and the debate continues while at least debate.minParticipants remain. The full record is written to the run artifacts; pi writes the synthesis.

Planning and execution

  1. A planner drafts a plan document; critics review it; the planner revises (up to planning.maxRevisions times).

  2. You approve, edit, ask for a revision, keep it as a draft, or discard it. The plan lives in <project>/.pi/master-orchestrator/plans/<id>/ and is meant to be versioned.

  3. Execution runs the steps of each block with the implementer role. Then the block is settled in a fixed number of runs:

    1. The reviewer reviews the block's whole change set, once. A correction never leads to another review.
    2. The implementer answers every finding in its own session: fixed (it makes the fix in the same run), rejected or deferred, with a reason.
    3. 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.
    4. Pi's model gives the verdict with the plan_verdict tool (accepted, needs_fix, blocked) and rules on each blocking finding that is still unsettled: fix or dismiss.

    needs_fix sends back only the findings ruled fix, plus the verdict's feedback, at most maxFixAttempts times 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 ruled fix that is still not fixed. Findings that end rejected, deferred or dismissed are listed in the final report.

  4. A failed or interrupted step pauses the plan and offers retry, skip, edit or abort. /plan resume continues after a restart, from the first step that is not done.

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

  1. Built-in defaults.
  2. User: ~/.pi/agent/master-orchestrator.json.
  3. 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 (a deny permission) report the refusal in their event stream.
  • Antigravity reports a permissions.deny rule as a failed tool step and goes on with the turn.
  • Codex leaves no trace of an execpolicy forbidden rule 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_call handler 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. They can contain source code and anything the worker printed. They stay on your machine, nothing is uploaded by this package, and directories older than defaults.artifactRetentionDays are removed at session start. 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.

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