Choosing Orchestration

Give your assistant the goal, a checkable stopping condition and a ceiling.

Choose a loop, dependency mission, growing mission or typed flow

Prompt-first procedure: Describe the outcome you want in your agent conversation. The agent should select and load the appropriate AIWG assets, explain material changes, request any needed approval, and report verification evidence. Exact commands and flags appear only in the CLI reference.

Start with a prompt

Give your assistant the goal, a checkable stopping condition and a ceiling. These prompts describe the intended host behavior; they are not new CLI commands.

StyleExample promptChoose it when
Plain Ralph loop“Reply with OK. Stop when output contains OK; allow at most two iterations.”One bounded objective can be checked repeatedly, without a declared task graph.
Mission with dependencies“Check left and right after collecting the root observation, then join both results. Preserve the other branch if one fails.”The tasks and prerequisites are known; selective recovery matters.
Evaluate then grow“Collect an observation, evaluate its evidence, then append a check of that lead if needed. Stop after one growth round or two total tasks.”The next task depends on what completed work reveals.
Typed flow“Judge approval as a boolean. Let the runtime select publish or reject from that output; reject is an optional failure branch.”A stable procedure needs validated inputs, outputs and declared routing.
Loop inside a node“Repair the left branch until its local check passes, at most three iterations. Release the join only after left and right complete.”One unit needs repeated verification while the graph owns the larger job.

Start with one loop for one objective. Add dependencies when preserving independent work matters; add growth when you cannot name all tasks upfront; use typed routing when you can declare the procedure and its branch conditions. A node-local loop can compose with dependencies, growth or typed routing. Typed routing and growth cannot share one plan: the conductor rejects it with `MISSION_MODE_CONFLICT` before dispatch.

Minimal declarations

Plain Ralph

Use the objective, completion criterion and explicit iteration ceiling. No MissionPlan or FlowPlaybook is needed. The CLI example is below, after the host contracts. See `$AIWG_ROOT/docs/addons/agent-loop/when-to-use-agent-loop.md` for choosing work with objective verification rather than subjective quality goals.

Declared dependencies

A MissionPlan needs `missionId`, `goal`, `completionCriterion` and `cycles`. Each task needs `id`, `runtime` and `prompt`. Declare `dependsOn` to enable the dependency cut; `[]` declares a root. The following diamond lists the join first intentionally: dispatch follows prerequisites, not array position.

{
  "missionId": "diamond", "goal": "Check two branches", "completionCriterion": "Join waits for both parents",
  "recoveryPolicy": { "version": 1, "attemptHistory": true, "inputIdentity": true },
  "cycles": [
    { "id": "join", "runtime": "codex", "prompt": "Join both results", "dependsOn": ["left", "right"] },
    { "id": "left", "runtime": "codex", "prompt": "Check left", "dependsOn": ["root"] },
    { "id": "right", "runtime": "codex", "prompt": "Check right", "dependsOn": ["root"] },
    { "id": "root", "runtime": "codex", "prompt": "Collect observation", "dependsOn": [] }
  ]
}

`recoveryPolicy` is optional: it adds bounded retry diagnostics and input identity tracking, not the dependency scheduler itself. With `recoveryPolicy.inputIdentity: true`, declare file values or digests in optional task `inputs` when file changes must invalidate completed work; without it, `inputs` don't affect identity.

Evaluate then grow

All seed and proposed tasks declare `dependsOn`. `taskCap` includes seed tasks; `maxRounds` defaults to 3, so set it explicitly for the prompt above.

{
  "missionId": "investigation", "goal": "Check the observed lead", "completionCriterion": "Lead checked",
  "growthPolicy": { "version": 1, "mode": "evaluate-then-grow", "maxRounds": 1, "taskCap": 2 },
  "cycles": [{ "id": "observe", "runtime": "codex", "prompt": "Collect observation", "dependsOn": [] }]
}

Pass the host callback as the `evaluateGrowth` option of `MissionConductor`, alongside `runWorker`:

const evaluateGrowth = ({ ledger, evidence }) => ({
  version: 1,
  reason: ledger.growth.rounds === 0 ? 'Check the observed lead' : 'Evidence is sufficient',
  evidence,
  cycles: ledger.growth.rounds === 0
    ? [{ id: 'check', runtime: 'codex', prompt: 'Check the lead', dependsOn: ['observe'] }]
    : [],
});

The callback receives current completed evidence references. It must return a reason and at least one current reference; workers cannot append tasks directly. An empty `cycles` list finishes evaluation without consuming a growth round.

Typed flow with declared successors

Use the existing `flow.aiwg.io/v1` FlowPlaybook. Every step declares a versioned input/output `contract` and `allowed_successors`. Terminals declare an empty list and `terminal_outcome`; optional branches use `contract.required: false`.

{
  "apiVersion": "flow.aiwg.io/v1", "kind": "FlowPlaybook", "metadata": { "name": "approval" },
  "spec": {
    "routing": { "version": 1, "entry": "judge", "maxTransitions": 4 },
    "steps": [
      {
        "id": "judge", "capability": "synthetic-judge",
        "contract": {
          "version": 1, "inputs": { "type": "object", "additionalProperties": false },
          "outputs": { "type": "object", "required": ["approved"], "additionalProperties": false,
            "properties": { "approved": { "type": "boolean" } } }
        },
        "allowed_successors": [
          { "step": "publish", "when": { "output": "/approved", "equals": true } },
          { "step": "reject", "when": { "output": "/approved", "equals": false } }
        ]
      },
      {
        "id": "publish", "capability": "synthetic-publish",
        "inputs": [{ "name": "approved", "from": "judge.approved" }],
        "contract": {
          "version": 1, "inputs": { "type": "object", "required": ["approved"],
            "additionalProperties": false, "properties": { "approved": { "const": true } } },
          "outputs": { "type": "string", "minLength": 1 }
        },
        "allowed_successors": [], "terminal_outcome": "success"
      },
      {
        "id": "reject", "capability": "synthetic-reject",
        "contract": { "version": 1, "required": false,
          "inputs": { "type": "object", "additionalProperties": false },
          "outputs": { "type": "string", "minLength": 1 } },
        "allowed_successors": [], "terminal_outcome": "failure"
      }
    ]
  }
}

The capability names above are synthetic, as in the offline test fixture; a real host must bind supported capabilities and preserve existing human gates before dispatch. Call `flowPlaybookToMission(playbook, bindStep)` from `src/flow/playbook-contracts`, then execute the returned plan with `new MissionConductor({ runWorker }).conduct(plan, pool)`. The binder supplies `{id: step.id, runtime: 'codex', prompt: step.id}` plus existing worker options. `pool` contains registered connected executors; `runWorker` is the host executor. It returns `{output: JSON.stringify(value), cost}`; a synthetic happy path returns `JSON.stringify({approved: true})` at judge and `JSON.stringify('done')` at publish.

`flow-run` is an MCP tool: it returns `ready_for_runtime_execution` and a required runtime contract for opted-in flows. It does not execute the graph. Legacy launch envelopes return `ready_for_host_execution`.

Loop inside the left node

Use the dependency example above and add this body only to `left`:

{ "version": 1, "criterion": "local check passes", "maxIterations": 3 }

Set `left.loop` to that object, then supply `verifyLoop` alongside `runWorker`. The host verifier returns `{passed: boolean, output: string}` after each successful worker execution. Map the criterion to a trusted local check; do not execute model-authored commands as the verifier. `runWorker` receives `invocation.loop`, including 1-based `iteration` and optional `previousVerifierOutput`. A FlowPlaybook step can declare the same `loop` field; projection retains it.

Failure, correction, retry and resume

StyleBehavior to plan for
Plain RalphThe external loop retains iteration state; completion and iteration/budget limits stop it. Resume uses persisted configuration unless explicitly overridden. A standalone loop has no declared dependency cut to preserve sibling tasks.
DependenciesDrain independent work first. A failure blocks descendants and preserves completed siblings. `authorizeRetry` must provide host-owned predecessor termination, task binding and resolved health evidence; one retry per node across resumes.
GrowthEvaluate only after the current dependency batch drains successfully. Validate proposals atomically. Outstanding failures stop evaluation until recovery. Over-budget proposals are recorded but never appended; `budget-exhausted` survives resume. Missing/throwing evaluators record `evaluation-failed`.
Typed flowValidate complete bound inputs and JSON output, then select exactly one matching successor. Invalid output gives `FLOW_INVALID_OUTPUT`; zero/multiple matches give `FLOW_ROUTE_UNRESOLVED`. Every executed visit, including a terminal, spends a transition. Resume requires the frozen plan and revalidates outputs/routes; drift gives `FLOW_RESUME_DRIFT`.
Node loopFirst passing host check ends the body. Exhaustion gives `MISSION_LOOP_EXHAUSTED`, blocks descendants and preserves siblings. Missing/throwing verifiers fail the node. Inner iterations release no descendants. The loop node consumes one typed transition visit; its extra inner iterations consume none. A graph retry requires the existing authorization and starts a fresh bounded body.

With `recoveryPolicy.inputIdentity`, changed declared specs, inputs or parent results invalidate only the affected task and descendants on resume. There are no implicit file read traces. An intentional same-spec correction uses `recoveryPolicy.corrections: ["left"]` on that resume; remove it afterward unless another correction is intended. Corrections cannot reset failed-node retry limits. Completed node bodies carry forward without replay; changing/removing a body requires input identity tracking. Typed plans also retain their frozen definition requirement. Resume growth with the same seed plan, policy and ledger: appended tasks and counters come from that ledger. Plan-only runs neither evaluate growth nor verify node bodies.

Terminal success and strict completion differ in typed flows. Read `flowRouting.completion.terminalOutcome`, `requiredStepCoverage` and `strictCompletion`: success can bypass a required step and leave strict completion false. These are runtime observations, not independent acceptance of worker claims. Host approvals and effect recovery remain in force for every style.

Evidence and cost caveats

Budget for graph variants usually costing more; do not assume a graph saves tokens or time. The shipped typed-flow comparison has higher agent cost in 16/18 rows; the recovery example saves tokens but is slower on intermediate edits. These are study-specific observations, not a measured AIWG ranking of these five styles. Plain Ralph and node loops still need ceilings; repeated local iterations add cost. Node results include all returned local iteration costs, but thrown calls cannot report unreturned spend.

The following quotations preserve the shipped caveats exactly. Dependency/recovery, growth and node-loop quotations come from Mission recovery; typed routing comes from Typed step contracts. Plain Ralph's comparison limit is the REF-3127 quotation; it is not broad evidence that loops underperform graphs.

Dependency recovery and plain-loop comparison

REF-3285 (fork() for Agents; arXiv 2026, corpus A−, GRADE MODERATE) reports prompt

repair with failure context fixed 14/18 versus 6/18 for blind retries, and recovery

100% versus 55% for whole replay. Injected failures always cleared on the first

retry, and the results are Claude-family only.

REF-3127 (From Agent Loops to Deterministic Graphs; preprint, GRADE VERY LOW)

reports hash-identity invalidation preserved unrelated work 3/3 versus 0/3 for both

loop baselines, with 382 versus about 11.7k input tokens. It was slower on

intermediate edits (73.6 s versus 31–39 s). The study used two tasks × three

repeats and one model family. These findings motivate the opt-in behavior; they

do not establish general recovery reliability. Read-trace fact propagation and

event-log replay/forking remain out of scope.

Evaluate then grow

REF-3289 (DAGent: Evaluate-then-Grow Planning; NeurIPS 2026 poster, corpus A−,

GRADE MODERATE) reports 47.3 / 55.3 / 65.0 on BrowseComp-Plus, GAIA and xbench

with Qwen3-32B, versus 42.0 / 50.5 / 61.0 for a same-family plan-then-patch

variant and 33.3 / 42.7 / 55.0 for a single upfront plan. Plan-then-patch costs

about 27–35% more wall time. These are scored short-answer tasks only; the core

result uses one mid-sized backbone, code is partial, and some ablations are near

seed variance. The findings motivate this opt-in mode without establishing broader

mission performance. Training-time DAGRPO and automatic topology learning remain

out of scope.

Typed routing

The issue quotes REF-3290 (STAGE, arXiv v3 preprint, GRADE LOW): typed judgments

with runtime-selected successors improved Pass³ in all 18 paired workflow–model

rows (+7.5 to +66.0 percentage points; Telecom, Luna 32.5% to 92.5%). Agent cost

was higher in 16 of 18 rows, with a median about 4.23×. The quoted model-routing

ablation scored 45.0% against 92.5% on Telecom, Luna. These are not AIWG results.

Caveats: about 50 proprietary cases per workflow, graph construction withheld,

and different baselines between v2 and v3.

REF-1905 is design only; REF-2005 is directional, without measurements here.

REF-2231 (Temporal, “fallacy of the graph”) cautions that static graphs handle

dynamic control flow, compensation and state poorly. Accordingly this feature

is opt in per flow and permits bounded loops. No corpus was available for this

implementation; these facts and caveats are limited to the issue's quotations.

Node-local loops

The loops-inside-graphs evidence is weak. REF-3293 (practitioner article “Loops and

Graphs”, grade C, GRADE VERY LOW) has no data and no measured outcomes. It suggests

local validation loops, correction of only the failed unit, and approval before

the first protected effect; it does not demonstrate a performance benefit.

REF-3285 (corpus A−) supports the node-level retry lifecycle. REF-3127 (VERY LOW)

reports losing unrelated work on updates, 0/3 for loops versus 3/3 for a DAG.

These issue-supplied observations motivate the opt-in shape; they are not AIWG

measurements or strong comparative evidence.

CLI reference and offline reproduction

For the plain-loop prompt (with an installed provider), the external CLI is:

Use AIWG to complete this documented outcome: For the plain-loop prompt (with an installed provider), the external CLI is
Have it inspect the current state, explain the plan, ask before material
changes, and report the result with verification evidence.

Inspect a current loop with the agent-owned ralph-external operation; resume an interrupted current loop with the agent-owned ralph-external operation. Completed loops are archived, so current-loop status can report no loop after success. Resume does not create a fresh graph or replenish its budgets. Host mission examples above use the conductor API, not an invented mission-execution CLI. In a source checkout, invoke the CLI as `node "$AIWG_ROOT/bin/aiwg.mjs"` after `npm run build:cli`.

The guide's regression tests execute these declarations with the existing offline mission-recovery fixtures and synthetic host callbacks, plus the external Ralph stub CLI. Every example runs in a fresh temporary git project with isolated HOME and AIWG_CONFIG. This checks declaration, routing and recovery behavior; synthetic workers do not establish that a model will interpret a prompt correctly or that research outcomes reproduce in AIWG.