# ultra 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 [args]`** — interactive command. Runs a saved workflow behind a live overlay: a per-agent board, `Tab`/`↑↓` to focus an agent and drill into its streaming transcript, steer a running sub-agent, and `Esc` to abort. UI only — headless callers use the tool. - **`workflow` tool** — model-callable, mid-turn. 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, background execution, 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 - [`skills/authoring-workflows/references/spec-format.md`](skills/authoring-workflows/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. ### Authoring The bundled **`authoring-workflows`** skill walks through co-designing and saving a workflow (phases, the read-only fan-out rule, schemas + join-keys, interpolation, where to save). It is model-invocable — ask to "create / author / save a workflow" and it activates. ### Where workflows live Discovery merges three locations, lowest-to-highest precedence (a later source overrides a bundled name): 1. **bundled** — `extensions/ultra/workflows/*.json` (ships with ultra) 2. **global** — `~/.pi/agent/workflows/*.json` 3. **project** — `/.pi/workflows/*.json` The shipped `review` workflow reviews the diff across dimensions, then adversarially verifies each finding — run it with `/ultra 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 → conditional implement → conditional security/quality review — run it with `/ultra feature ` (the whole trailing text is the task). Implementation runs only when critique approves the plan. 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 bug `. The fix runs only after the regression phase proves the expected failure; verification runs only after a fix. ## Results The `workflow` tool accepts `background: true` to start a run and return immediately. When the detached run finishes, ultra sends its result back into the conversation. `/ultra-runs` opens a saved-run picker for inspecting, resuming, stopping, or deleting runs. Run records live under `~/.pi/agent/ultra-runs/`. 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. Expanded workflow tool output renders every phase from the start and each known sub-agent as a multiline block. The tool header shows total workflow wall time while running and freezes it at completion. Known agents appear queued before launch; dynamic fan-outs show `agents not planned yet`; conditional phases show `conditional` until their selectors resolve. Rows then transition through queued, running, done, dropped, or skipped without disappearing. Verified Nerd Font icons reinforce each state while text labels preserve meaning without glyph support. Configured tiers are shown as `tier → provider/model`; collapsed output remains counts-only. 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, `/.pi/settings.json`, and `/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.modelTiers` | `{}` | Optional `small` / `medium` / `big` model aliases. | `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`), used when the step omits `thinkingLevel`. Bundled workflows explicitly assign tiers by phase role and thinking levels by relative complexity. ```json { "ultra": { "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`). Either way the step's `tools` allowlist is the only gate on what's active, and ultra's own `workflow` tool is never grantable to a sub-agent. Workflows should name **tools**, never extensions — a workflow that lists a tool no installed extension provides simply runs without it. ## Install / load This extension is loaded through the root pi-ext package. See [../../README.md](../../README.md).