Skip to main content
These patterns combine the handler fields into the shapes that come up most often. Each is a starting point, not a rule.

Guard with escalation

Block a handler and route the failure to a named event instead of rejecting it.
on_fail is one of reject (default), discard, kill, or escalate:{event}. See Guards.

Multi-gate pipeline

Track sub-steps with gates, then reset them when re-entering a cycle.
See Writing data and advancing state.

Accumulate and compute

Wait for several items, aggregate them, then branch on the result.
See Accumulation and computation.

Fan out

Dispatch one event per item; each event resolves into its own template-flow instance (with its own agent), and a staged join: owns completion.
Delivery is receiver-owned: the template flow’s input pin decides whether each item gets a new instance or joins an existing one, so you get one instance and one agent per item. Completion is owned by a fan-in barrier, not by counting in the handler — see examples/routing/fan-in/barrier and Parallel work.

Rules-based routing

Dispatch on a payload field. rules is a list; the matched rule owns the emit.
rules and on_complete are mutually exclusive; using both is a load-time error caught by swarm verify. See Branching.

Dynamic flow instances

One instance (and one entity) per order or customer. The usual way needs no creation call at all — the template flow’s input pin mints the instance when the first event for a new identity arrives:
fulfillment/schema.yaml
When you need to create an instance explicitly from a handler (to pass extra config in), use the create_flow_instance action instead — see Composing flows for that form and the return path. Either way, results come back through the child’s output pin and a connect edge; the carried identity does the addressing.

Timers

“An entity sat here too long” is a stage timer — declared on the stage, armed on entry, cancelled when the entity leaves:
schema.yaml
{{...}} reads a value from the flow’s policy. For time that a stage cannot anchor — event-triggered delays, or boot-anchored recurring work like a nightly report — declare a node timer with start_on: event:<name> or start_on: boot (see nodes.yaml).

Cross-entity queries

Read across entities to build a report.
query accepts either a single query object or a list of them (as here), and each store_as target is an entity field. store_as is always entity-prefixed (entity.<field>).

Payload transform

Build an output payload from entity state, payload, and policy with emit.fields — and when names match, from: entity fills the required same-named fields for you (see Emitting events).
See Emitting events.

Keep reviewers independent

When two agents must not share context, give a role two pools (independent groups of sessions for the same agent role) with different subscriptions: route originals to one and appeals to the other. Same prompt, separate sessions, no shared context.