Skip to main content

Routers

A router decides which node runs next. Attach it to an edge and list every node it may choose:

field_match: deterministic routing

field_match reads one field of the previous node’s JSON output and looks its value up in routes. default is used when the field is missing or the value is not listed. It makes no model call: the same input always takes the same path. This is the router to use in most production workflows. Pair it with an agent whose parser returns that field as an enum, or with a function that computes it.

Pattern: skip what is not there

Route around optional steps instead of letting them fail. For example, check whether a file was uploaded before downloading it (a fragment; the rest of the workflow is omitted):
Quote "yes" and "no" (and "on", "off") when they are keys in YAML. Unquoted, YAML reads them as booleans.

Model-based routers

These routers ask a model to choose, which suits conversational or open-ended flows. Each needs a model and its own settings: See the FloAI routing reference for their options. Prefer field_match whenever the decision can be made from data.

ForEach

A ForEach node runs a sub-workflow once per item and can hand all the results to the next node.
How it behaves:
  • Items are messages. ForEach runs once for each message its input_filter selects. Run the workflow above with three input messages and review_one runs three times. A single message containing a JSON array is one item. To iterate over the elements of a list, send them as separate input messages, or let a node upstream produce one output per element.
  • The executed node must be a sub-workflow (declared under ariums). Naming a plain function or agent as execute_node is rejected, because the validator sees it as an orphan node.
  • Results: with forward_all_results: true, every item’s result is stored under the ForEach node’s name, and a function selecting it gets them all in node_outputs.each_item (a list, one entry per item). With the default false, only the last item’s result is kept.
  • Sequential: items are processed one after another, not in parallel.
  • iterators and foreach_nodes are two names for the same list.