Control flow: conditions, loops, gates

The four connection flow types (Always, Conditional, Approval Gate, Loop) and when to use which.

Every connection has a flow type that controls when it fires. Four types are supported. Open the Connection Config popup (double-click a connection) and pick from the Flow Type buttons, or use the right-click → Flow Type submenu for a quick switch.

Always (default)

The downstream agent runs as soon as the upstream finishes. No conditions, no gates. This is what you want 95% of the time.

Edge appearance: solid line, role-accent gradient.

Conditional

The downstream runs only if a natural-language condition evaluates true on the upstream's output.

Open Connection Config and fill in:

  • Condition: natural-language. e.g. "the researcher's output mentions Horizon Europe funding."
  • Edge label: short text shown on the edge (optional).
  • This is the "otherwise" / else branch: if checked, the edge fires when the condition is false.

Conditional edges are evaluated by a quick yes/no model check over the upstream output. It's a tiny call, and its cost is counted in the run total. If the check itself fails (e.g. a provider outage), Cerevisor plays it safe: the branch is treated as not met and the downstream agent is skipped.

When to use

  • Routing: send "high confidence" results to a fast writer, "low confidence" to a senior reviewer.
  • Branching: if a researcher finds no sources, send to an escalation agent instead of the writer.
  • Veto: if a reviewer says "this is wrong", route back to the original author instead of proceeding.

Patterns

Two conditional edges from the same source with the same condition text — one normal, one with the else branch box checked — give you an if/else split: one fires when the condition holds, the other when it doesn't.

Cumulative conditions across multiple edges (three different criteria, three different downstream agents) all fire independently.

Approval Gate

The workflow pauses. An approval card appears (on the waiting agent) showing the upstream's output and your approval prompt. Click Approve to continue or Reject to skip the downstream agent — the rest of the workflow keeps going. If you don't answer within the timeout (5 minutes by default), the gate counts as rejected instead of stalling the run forever.

Configure:

  • Approval prompt: the text shown to you when the gate opens. E.g. "Is this research solid enough to publish?"

When to use

  • High-stakes decisions: before a content agent publishes, before a code agent deploys.
  • Cost gates: before a long-running expensive agent kicks off.
  • Quality gates: review the upstream output before letting the workflow continue.

The agent on the upstream side of a gate completes normally; the gate sits between completion and downstream startup.

Loop

A loop edge points backward: from a later agent (the source) to an earlier one (the target). After all waves have run once, Cerevisor re-runs the stretch from the target through the source — target, everything downstream of it, and anything connected through shared files — until the exit condition holds for the source's output, or the iteration cap is reached.

Configure:

  • Loop condition: natural-language exit criterion, checked against the source agent's output before each extra pass. E.g. "the draft is at least 600 words and includes all three required sections." Leave it empty for a fixed-count loop that always runs the full number of iterations.
  • Max iterations: default 3, up to 10. Hard cap to prevent runaway.

When to use

  • Refine until done: draft → critique → revise until the critique passes.
  • Iterative search: query → assess → refine query.
  • Convergence: optimization passes that improve a metric.

Each pass re-runs the looped agents fresh, seeded with the current outputs of everything else; agents outside the loop keep their results. The small cost of the exit-condition checks is counted in the run total.

If the cap is hit without the condition passing, the loop exits with the last pass's output and the workflow continues.

Mixing flow types

You can have one source agent with multiple outgoing edges, each a different flow type:

  • An Always edge to a writer (the normal path).
  • An Approval Gate edge to a publisher (you sign off before publishing).
  • A Conditional edge to an escalation agent (if researcher's confidence < 0.6).

The orchestrator evaluates each edge independently. The conditional fires (or doesn't) based on its condition; the gate pauses regardless.

Visual cues on edges

Flow type Edge style Badge
Always Solid, role-accent gradient (none)
Conditional Solid (dashed + dimmer for the else branch) ◆ with your edge label, or "Otherwise" on the else branch
Approval Gate Dashed ⏸ "Approval"
Loop Dashed, animated ↻ with the condition snippet and max iterations, e.g. "Loop (max 3)"

Back to docs