Skip to content

Circuit breakers

A ‡ Circuit breaker watches what flows past it and reacts when a condition fires. Stopping the run, starving a branch, or parking for a human.

Breakers are reactive, not predictive. They read live metrics after steps have run. They are not a cost forecast.

For routing to labeled branches (pass / fail / unsure), use a Judge instead. Fuse vs branch.

A circuit breaker between an agent and an output: when its condition holds the value passes through. When it trips the run aborts, skips the branch, or parks for a human.

One node, two outcomes. The mode decides what it watches. The action decides what happens when it fires.


LayerScopeWhere
Graph spend ceilingThe whole run≔ params → spend ceiling (USD)
Circuit breaker nodeOne wire / one branchDropped on the canvas

The ceiling is checked between parallelism waves and aborts the run. Nodes are checked when the wire carries a value.


ModeTrips whenConfigure
spendRun spend ≥ thresholdthresholdUsd
tokensInbound tokens ≥ threshold (known session tokens, else a chars ÷ 4 estimate)thresholdTokens
durationWall-clock since run start ≥ thresholdthresholdMs
contentText is empty, shorter than a minimum, or matches / fails to match a regexminChars, pattern, tripOnMatch
retriesAccumulated run failures ≥ thresholdthresholdRetries

Content is the subtle one. With a pattern and tripOnMatch: true it fires when the text matches (catch ERROR). Left false, it fires when the text fails to match. An assertion that the output contains what it must. With neither minChars nor pattern, it simply trips on empty text.

An invalid regex trips rather than passing silently, so a broken guard can’t pretend to be a working one.


ActionEffect
abortStop the run
skipFail this node. Downstream starves. The rest of the graph continues
parkPause and hand the text to a human. The same editable dock as an approval gate

Detached runs have nobody to ask: with --approve-all a parked circuit breaker auto-passes and says so in the log. Without it, the run refuses to start.


Every evaluation is logged, whether it fires or not:

‡ circuit breaker ok — spend $0.8400 < $5
‡ circuit breaker — content did not match /PASS/ → park

That makes a quiet circuit breaker auditable: you can prove the guard ran and saw a healthy value.


The seatbelt. A spend ceiling on every graph you run unattended. Costs nothing, prevents the runaway.

The quality gate. content + minChars after a drafting agent. A two-sentence “draft” parks for review instead of flowing into the implement stage.

The assertion. content + pattern: "All tests pass" on a test-runner branch: trips when the phrase is absent.

The deadline. duration + skip on an optional enrichment branch: if the run is already slow, drop the nice-to-have and keep going.

The flake budget. retries + abort at 3. Tolerate two hiccups, give up on the third.


▶ Content breaker · Min-chars breaker · Spend ceiling · Token breaker · Guarded parallel