delegation-chain is an archived example, not installed by init. Copy
examples/init-pack/delegation-chain.tsx and its dependency closure into your
project, or ask create-workflow to build an equivalent.
Once installed, it runs the whole arc from an ambiguous ask to gated, scored
delivery: strong models refine and decompose the goal into tiered chunks, cheap
models render previews and probes, and every node gates its own execution
(reviews, checks, previews, optional approvals). Outputs stay editable
throughout, and the run ends with scorers plus a short poll (see How It Runs,
Live control, and Scoring below).
Inputs
Only
prompt is required; everything else defaults to automatic operation.
Example with a policy and a budget:
Tiers
Work flows down a ladder of intelligence tiers: labels (fable, opus,
sonnet, haiku by default), not model ids. The copied workflow maps each
label to an agent (or failover chain) from .smithers/agents.ts, so you can
swap any tier without touching the workflow body. By default the strongest
tier plans the root and reviews, the second plans chunks, the third executes
leaves, and the cheapest renders previews and research probes at near-zero
cost.
How It Runs
- Goal refinement. The strongest tier forecasts every user-preference question upfront and answers implementation questions itself; the cheapest tier pre-renders the question forms (10 by default) so you never wait on rendering, answering one durable form at a time in the UI. The goal agent writes the refined prompt; your approval (edited first if you like) becomes the root planning brief.
- Tiered decomposition. The root plan streams in children; each child
declared a chunk fans out into its own plan task at its own tier, level by
level, until the frontier is all leaves or
maxDepthforces it. Every plan carries per-child{ tokens, costUsd, minutes }estimates, a subtree rollup, and a risk list with a probe verdict each (poc,research, ornullfor “judged routine”, scored later). - Zero-backpressure previews. Once planning completes, the cheapest tier
renders every leaf’s expected output: calibration only, tagged “never
executed”, so you catch misunderstood briefs before spending execution
cost. The UI’s skip button sends a durable
dc-skip-previewsignal that suppresses the phase. - Backpressure planning. Every node declares its gates and dependencies
before execution:
reviewgates at a declared tier,checkgates as shell commands,previewgates (developer previews, below), andapprovalgates, permitted only with a passedapprovalPolicy(none means no approval gates). With a policy, delegating agents add gates only where it applies, optionally clarifying it for children. The root node must declare aslideshowdeveloper preview, so every run ends with something showable. - Derisk loop. Every flagged risk spawns a probe:
researchprobes read docs and report with sources,pocprobes prove the risky thing works. Findings go to the nearest parent only; no node sees the whole tree. A finding that changes the plan triggers a replan round: the flagged node’s owner plus every dependent (child and dependency edges both) decideinvalidated(version bump, fresh plan, old version archived) orreaffirmed(“my plan survives the change”). Rounds stop atmaxDeriskRoundsper node. - Execution. Leaves run in dependency order at
maxConcurrencyparallelism: a leaf’s pipeline mounts only once every leaf under its dependencies completes. Each leaf loops exec plus gates up tomaxAttemptstimes, folding failed-gate feedback into the next attempt’s brief. Reviews judge evidence, not summaries: each gets the node’s structured output plus the measured range of jj (or git) commits produced, with instructions to inspect them (jj log,jj diff,jj show). Chunk-level reviews get the union of their subtree’s ranges. - Scoring and poll. A run-level digest task carries the five delegation
scorers, and (unless
poll: false) a final 3-question satisfaction poll renders in the UI as the run’s last attention badge.
Live control while it runs
The whole run is steerable from thedelegation-chain workflow UI:
- Editable outputs. Every rendered output is editable in place. Saving an
edit sends a durable
dc-editsignal riding the same replan cascade as a probe finding: the affected owner replans or reaffirms, and dependents cascade. Edits are ordinary events, not restarts. - Version history. Invalidation bumps a node’s version and archives the old one. Clicking a node shows its version list: every prior version stays inspectable, with the replan decision that killed it.
- Attention routing. Nodes carry a pending-human rollup (self plus descendants); clicking a pulsing badge jumps to the nearest descendant that needs you: a question, the refined-prompt approval, an approval gate, or the poll.
- Cost bar. The header shows actual spend against the latest predicted total; replans re-forecast, so the prediction is always the newest rollup, not the first guess.
- Developer previews. Nodes with a
previewgate build a showable artifact after execution:app(the built thing itself),terminal(rendered terminal plus driving instructions),api(an explorer over a built API),throwaway-ui(a disposable UI over the work), orslideshow(an HTML slideshow, the fallback with no runnable code). The build is backpressure: a failed build fails the node like a failed review. Its Invalidate and Request-changes buttons submit the samedc-editround as any other edit.
Budgets
PassbudgetUsd and/or budgetMinutes to enforce the forecast: rolled-up
actuals are checked after each leaf’s execution, crossing 80% of a limit
writes a warning row and crossing it raises an error into the run.
budgetMinutes also acts as a wall-clock latency SLO on the whole chain.
Scoring
Five scorers grade the run (see the scorer reference):
The run total combines them via
delegationRunScore, weighted 0.25 / 0.25 /
0.15 / 0.15 / 0.2 by default; skipped components drop out and the rest
renormalize. All weights, plus the per-classification values and penalties
inside pocJudgment and planSolidity, are configurable via the scorer
factory options.
Roadmap
One follow-up is deliberately deferred: higher-order orchestration (a planning node authoring its own smithers workflow as its execution strategy), reserved via the optionaldcPlan.orchestration: "tasks" | "workflow" field,
accepted but ignored today. The UI-side fold store behind useDelegationChain
already runs on Effect.ts, behind the frozen hook signature.
Use it when
- The ask is ambiguous or large enough to deserve refinement, decomposition, and risk probes before anyone writes code.
- You want per-node backpressure with evidence (commit-range reviews, checks, showable previews) instead of one final review.
- You want to steer mid-flight by editing outputs rather than restarting.
Use something else when
- The change is a single focused unit: use
implement. - You want milestone-by-milestone delivery with one approval gate: use
mission. - You only need the gate matrix, not the delegation: use
backpressure-plan.
<DelegationChain> composite; use that page
to embed the same machinery in your own workflows.