Multi-agent workflow orchestration for Pi. A declarative JSON spec fans sub-agents
out across phases under a concurrency cap, validates their structured output, and
aggregates the results — with live progress on both an interactive overlay and a
model-callable tool surface.
Two surfaces
/ultra: enables the hidden workflow tool for later agent turns, confirms activation, and does not start a turn.
/ultra exec <instructions>: enables the tool, sends the complete orchestration prompt as a visible user message, and starts an agent turn to choose, design, or run a workflow.
/ultra run <name> [args]: runs a saved workflow behind a phase-first live overlay with keyboard phase toggling, agent focus, streaming transcripts, steering, targeted abort, and confirmed whole-run abort.
workflow tool: model-callable after /ultra enables it. Pass a saved
workflow name (+ optional args), or an inline spec object for a one-off
run. Returns the aggregated JSON; progress streams to a collapsible result
surface.
Workflows
Use ultra for fan-out, multi-phase orchestration, or a single agent that specifically needs isolation, an alternate model, resumability, or strict structured output.
For an ordinary one-agent task, perform the task directly instead of wrapping it in ultra.
A workflow is a single JSON object — phases (single / fanout), per-step
prompts/tools/schemas, and a closed interpolation grammar that pipes one phase's
results into the next. The authoritative format reference is
— the single source of truth, kept in lockstep with the runtime validator by a
test. Don't reconstruct the format from memory; read it.
Authoring
Run /ultra exec <instructions> to send the complete orchestration prompt as a visible user message and enable the workflow tool for the next agent turn.
The agent chooses an ephemeral one-off or persisted workflow when confidence is high, and asks one focused question when it is not.
Persisted authoring covers phases, the read-only fan-out rule, schemas + join-keys, interpolation, and where to save.
Where workflows live
Discovery merges three locations, lowest-to-highest precedence (a later source
overrides a bundled name).
Workflow files are rescanned on every completion or invocation, so newly saved JSON works immediately without /reload.
bundled — extensions/ultra/workflows/*.json (ships with ultra)
global — ~/.pi/agent/workflows/*.json
project — <cwd>/.pi/workflows/*.json
The shipped review workflow reviews the diff across dimensions, adversarially verifies each finding, then synthesizes a concise analysis with concrete next steps.
Run it with /ultra run review [base-ref] (no base ref reviews the working tree; a base ref reviews everything since it).
The shipped feature workflow drives a small feature end to end —
research → plan → adversarial critique → strengthened plan → implement → conditional security/quality review —
run it with /ultra run feature <describe the task> (the whole trailing text is the task).
A dedicated read-only phase rewrites the plan to resolve critique blockers before implementation.
Only its implement phase writes; every other phase is read-only.
The shipped bug workflow drives investigate → regression test → conditional fix → adversarial verification.
Run it with /ultra run bug <describe the bug>.
The fix runs only after the regression phase proves the expected failure; verification runs only after a fix.
The shipped research workflow drives question planning → parallel multi-source evidence gathering → gap and contradiction audit → targeted adversarial verification → cited synthesis.
Run it with /ultra run research <question>.
Its fan-out phases use the web_search, web_fetch, and web_map tools shipped by the web extension.
Results
Completed review runs show synthesized analysis, verified and refuted findings, drops, and concrete recommended next steps.
Expand the result only when raw JSON is needed.
Workflow runs append incomplete-run checkpoints to the current Pi session as custom entries that never enter LLM context.
If a run is aborted, the next matching run on the same session branch reuses completed steps and runs the missing or changed steps.
A completed run appends a completion marker, so later runs start fresh.
Both progress surfaces use the same phase-first hierarchy, authored step summaries, status language, icons, elapsed time, counts, checkpoint state, token usage, and cost.
The overlay also shows each exact resolved sub-agent prompt as the first user message in its transcript.
Sub-agent tool calls keep one native Pi tool row from invocation through result and follow Pi's global expand state.
Collapsed workflow tool output remains counts-only with Pi's standard expand hint.
Expanded tool output summarizes every phase, automatically opens the active and failed phases, shows their agents, and ends with the human-readable workflow outcome.
The command overlay uses the same board, automatically collapses completed phases, and adds keyboard interaction.
Use ↑/↓ to focus visible phase or agent rows, Enter to toggle a phase, and Tab to cycle visible agents.
Use Alt+↑/Alt+↓ to scroll the focused transcript, s to steer, and x to abort the focused agent.
Aborting the whole run requires two Esc presses within 1.5 seconds.
Known agents appear queued before launch; dynamic fan-outs show agents not planned yet; conditional phases show conditional until their selectors resolve.
Rows transition through queued, running, done, dropped, or skipped without disappearing from their phase summary.
Configured tiers are shown as tier → provider/model.
Workflow results include aggregate token and cost usage from completed sub-agent turns when the provider reports it.
The final JSON contains tokenUsage with input, output, total, cacheRead, cacheWrite, and cost.
Every dropped step produces a typed diagnostic in phaseFailures with its code, message, retryability, attempt count, model, thinking level, original item, and a bounded final transcript tail when available.
Collapsed output shows only short failure reasons; expanded output shows the diagnostic fields.
A later phase may consume {PHASE.failures} through when, over, prompts, or return to perform one explicit linear recovery pass.
Ultra never drops work because of elapsed time and never creates automatic recovery loops.
Settings
Read from the ultra block of agent settings, <cwd>/.pi/settings.json, and
<cwd>/settings.json (later overriding earlier), with the runtime settings
manager on top.
Key
Default
Meaning
ultra.enabled
true
When false, the tool + command refuse to run.
ultra.concurrency
5
Max concurrent sub-agents in a fanout phase.
ultra.maxRetries
2
Tool-less transport/output retries per step.
ultra.subagentExtensions
"all"
Load host extensions into sub-agents, or not.
ultra.subagentSkills
"all"
Load host skills into sub-agents, or not.
ultra.modelTiers
{}
Optional small / medium / big model aliases.
ultra.actionSummarizerModel
null
Fast model for concise tool-action phrases; off when null.
ultra.actionSummarizerModel accepts a concrete provider/model ref.
Ultra immediately renders a terse tool-aware action such as Reading settings.ts, then replaces it with the best-effort LLM phrase when available.
Collapsed transcripts hide redundant tool previews; expand tools to inspect their complete native Pi arguments and results.
Requests use bounded input, 40 output tokens, no retries, no prompt caching, and a two-second timeout.
Rapid actions coalesce independently per agent, only one request runs at once, and an agent's final pending action flushes when it finishes.
Workflow completion cancels leftover requests.
Failures keep the deterministic fallback and never affect workflow execution.
Unknown tool arguments and results use bounded top-level JSON summaries instead of raw JSON dumps.
Tool arguments are sent to the configured model without secret redaction.
ultra.modelTiers maps workflow step model values of small, medium, or big to concrete model refs.
Unset tiers fall back to the session model.
A tier value may end with a thinking suffix (:off, :minimal, :low, :medium, :high, :xhigh, :max), used when the step omits thinkingLevel; max is the highest opt-in budget and requires model support.
Bundled workflows explicitly assign tiers by phase role and thinking levels by relative complexity.
ultra.subagentExtensions ("all" | "none", default "all") controls whether
workflow sub-agents load the host's extensions. With "all", a step can grant any
tool an installed extension provides (e.g. web_search); with "none", sub-agents
are isolated to the core tools (bash, find, grep, ls, read, ripgrep).
The step's tools allowlist gates extension tools, and ultra's own workflow
tool is never grantable to a sub-agent. Workflows should name tools, never
extensions. Ultra refuses to start a workflow when a listed tool is unavailable
to its sub-agents.
ultra.subagentSkills ("all" | "none", default "all") controls skill
discovery for tool-using workflow sub-agents. Skills use Pi's normal global,
project, package, and settings discovery, plus extension discovery when
ultra.subagentExtensions is "all". "all" also grants the
built-in read tool so the agent can load selected SKILL.md files; every other
tool remains workflow-gated. "none" omits all skills. Tool-less workflow steps
are direct model calls rather than Pi agent sessions, so they cannot load skills.
Install / load
This extension is loaded through the root pi-ext package.
See ../../README.md.
# ultraMulti-agent workflow orchestration for Pi. A declarative JSON spec fans sub-agents
out across phases under a concurrency cap, validates their structured output, and
aggregates the results — with live progress on both an interactive overlay and a
model-callable tool surface.
## Two surfaces- **`/ultra`**: enables the hidden `workflow` tool for later agent turns, confirms activation, and does not start a turn.
- **`/ultra exec <instructions>`**: enables the tool, sends the complete orchestration prompt as a visible user message, and starts an agent turn to choose, design, or run a workflow.
- **`/ultra run <name> [args]`**: runs a saved workflow behind a phase-first live overlay with keyboard phase toggling, agent focus, streaming transcripts, steering, targeted abort, and confirmed whole-run abort.
- **`workflow` tool**: model-callable after `/ultra` enables it. Pass a saved
workflow `name` (+ optional `args`), or an inline `spec` object for a one-off
run. Returns the aggregated JSON; progress streams to a collapsible result
surface.
## WorkflowsUse ultra for fan-out, multi-phase orchestration, or a single agent that specifically needs isolation, an alternate model, resumability, or strict structured output.
For an ordinary one-agent task, perform the task directly instead of wrapping it in ultra.
A workflow is a single JSON object — phases (`single` / `fanout`), per-step
prompts/tools/schemas, and a closed interpolation grammar that pipes one phase's
results into the next. The authoritative format reference is
- [`prompts/references/spec-format.md`](prompts/references/spec-format.md)
— the single source of truth, kept in lockstep with the runtime validator by a
test. Don't reconstruct the format from memory; read it.
### AuthoringRun `/ultra exec <instructions>` to send the complete orchestration prompt as a visible user message and enable the `workflow` tool for the next agent turn.
The agent chooses an ephemeral one-off or persisted workflow when confidence is high, and asks one focused question when it is not.
Persisted authoring covers phases, the read-only fan-out rule, schemas + join-keys, interpolation, and where to save.
### Where workflows liveDiscovery merges three locations, lowest-to-highest precedence (a later source
overrides a bundled name).
Workflow files are rescanned on every completion or invocation, so newly saved JSON works immediately without `/reload`.
1. **bundled** — `extensions/ultra/workflows/*.json` (ships with ultra)
2. **global** — `~/.pi/agent/workflows/*.json`
3. **project** — `<cwd>/.pi/workflows/*.json`
The shipped `review` workflow reviews the diff across dimensions, adversarially verifies each finding, then synthesizes a concise analysis with concrete next steps.
Run it with `/ultra run review [base-ref]` (no base ref reviews the working tree; a base ref reviews everything since it).
The shipped `feature` workflow drives a small feature end to end —
research → plan → adversarial critique → strengthened plan → implement → conditional security/quality review —
run it with `/ultra run feature <describe the task>` (the whole trailing text is the task).
A dedicated read-only phase rewrites the plan to resolve critique blockers before implementation.
Only its `implement` phase writes; every other phase is read-only.
The shipped `bug` workflow drives investigate → regression test → conditional fix → adversarial verification.
Run it with `/ultra run bug <describe the bug>`.
The fix runs only after the regression phase proves the expected failure; verification runs only after a fix.
The shipped `research` workflow drives question planning → parallel multi-source evidence gathering → gap and contradiction audit → targeted adversarial verification → cited synthesis.
Run it with `/ultra run research <question>`.
Its fan-out phases use the `web_search`, `web_fetch`, and `web_map` tools shipped by the `web` extension.
## ResultsCompleted review runs show synthesized analysis, verified and refuted findings, drops, and concrete recommended next steps.
Expand the result only when raw JSON is needed.
Workflow runs append incomplete-run checkpoints to the current Pi session as custom entries that never enter LLM context.
If a run is aborted, the next matching run on the same session branch reuses completed steps and runs the missing or changed steps.
A completed run appends a completion marker, so later runs start fresh.
Both progress surfaces use the same phase-first hierarchy, authored step summaries, status language, icons, elapsed time, counts, checkpoint state, token usage, and cost.
The overlay also shows each exact resolved sub-agent prompt as the first user message in its transcript.
Sub-agent tool calls keep one native Pi tool row from invocation through result and follow Pi's global expand state.
Collapsed workflow tool output remains counts-only with Pi's standard expand hint.
Expanded tool output summarizes every phase, automatically opens the active and failed phases, shows their agents, and ends with the human-readable workflow outcome.
The command overlay uses the same board, automatically collapses completed phases, and adds keyboard interaction.
Use `↑`/`↓` to focus visible phase or agent rows, `Enter` to toggle a phase, and `Tab` to cycle visible agents.
Use `Alt+↑`/`Alt+↓` to scroll the focused transcript, `s` to steer, and `x` to abort the focused agent.
Aborting the whole run requires two `Esc` presses within 1.5 seconds.
Known agents appear queued before launch; dynamic fan-outs show `agents not planned yet`; conditional phases show `conditional` until their selectors resolve.
Rows transition through queued, running, done, dropped, or skipped without disappearing from their phase summary.
Configured tiers are shown as `tier → provider/model`.
Workflow results include aggregate token and cost usage from completed sub-agent turns when the provider reports it.
The final JSON contains `tokenUsage` with `input`, `output`, `total`, `cacheRead`, `cacheWrite`, and `cost`.
Every dropped step produces a typed diagnostic in `phaseFailures` with its code, message, retryability, attempt count, model, thinking level, original item, and a bounded final transcript tail when available.
Collapsed output shows only short failure reasons; expanded output shows the diagnostic fields.
A later phase may consume `{PHASE.failures}` through `when`, `over`, prompts, or `return` to perform one explicit linear recovery pass.
Ultra never drops work because of elapsed time and never creates automatic recovery loops.
## SettingsRead from the `ultra` block of agent settings, `<cwd>/.pi/settings.json`, and
`<cwd>/settings.json` (later overriding earlier), with the runtime settings
manager on top.
| Key | Default | Meaning |
| ----------------------------- | ------- | ---------------------------------------------------------- |
| `ultra.enabled` | `true` | When false, the tool + command refuse to run. |
| `ultra.concurrency` | `5` | Max concurrent sub-agents in a `fanout` phase. |
| `ultra.maxRetries` | `2` | Tool-less transport/output retries per step. |
| `ultra.subagentExtensions` | `"all"` | Load host extensions into sub-agents, or not. |
| `ultra.subagentSkills` | `"all"` | Load host skills into sub-agents, or not. |
| `ultra.modelTiers` | `{}` | Optional `small` / `medium` / `big` model aliases. |
| `ultra.actionSummarizerModel` | `null` | Fast model for concise tool-action phrases; off when null. |
`ultra.actionSummarizerModel` accepts a concrete `provider/model` ref.
Ultra immediately renders a terse tool-aware action such as `Reading settings.ts`, then replaces it with the best-effort LLM phrase when available.
Collapsed transcripts hide redundant tool previews; expand tools to inspect their complete native Pi arguments and results.
Requests use bounded input, 40 output tokens, no retries, no prompt caching, and a two-second timeout.
Rapid actions coalesce independently per agent, only one request runs at once, and an agent's final pending action flushes when it finishes.
Workflow completion cancels leftover requests.
Failures keep the deterministic fallback and never affect workflow execution.
Unknown tool arguments and results use bounded top-level JSON summaries instead of raw JSON dumps.
Tool arguments are sent to the configured model without secret redaction.
`ultra.modelTiers` maps workflow step `model` values of `small`, `medium`, or `big` to concrete model refs.
Unset tiers fall back to the session model.
A tier value may end with a thinking suffix (`:off`, `:minimal`, `:low`, `:medium`, `:high`, `:xhigh`, `:max`), used when the step omits `thinkingLevel`; `max` is the highest opt-in budget and requires model support.
Bundled workflows explicitly assign tiers by phase role and thinking levels by relative complexity.
```json{
"ultra": {
"actionSummarizerModel": "openai/gpt-5-mini",
"modelTiers": {
"small": "openai/gpt-5-mini:low",
"medium": "anthropic/claude-sonnet-4:medium",
"big": "openai/gpt-5.1:xhigh" }
}
}
```
`ultra.subagentExtensions` (`"all"` | `"none"`, default `"all"`) controls whether
workflow sub-agents load the host's extensions. With `"all"`, a step can grant any
tool an installed extension provides (e.g. `web_search`); with `"none"`, sub-agents
are isolated to the core tools (`bash`, `find`, `grep`, `ls`, `read`, `ripgrep`).
The step's `tools` allowlist gates extension tools, and ultra's own `workflow`
tool is never grantable to a sub-agent. Workflows should name **tools**, never
extensions. Ultra refuses to start a workflow when a listed tool is unavailable
to its sub-agents.
`ultra.subagentSkills` (`"all"` | `"none"`, default `"all"`) controls skill
discovery for tool-using workflow sub-agents. Skills use Pi's normal global,
project, package, and settings discovery, plus extension discovery when
`ultra.subagentExtensions` is `"all"`. `"all"` also grants the
built-in `read` tool so the agent can load selected `SKILL.md` files; every other
tool remains workflow-gated. `"none"` omits all skills. Tool-less workflow steps
are direct model calls rather than Pi agent sessions, so they cannot load skills.
## Install / loadThis extension is loaded through the root pi-ext package.
See [../../README.md](../../README.md).