Skip to main content

Overview

A FlowConfig describes a conversation flow as data: the nodes, what each one says, which tools each node offers, and where each tool leads. It contains no Python callables. Every tool it references is a Flows direct function that lives in your code and is resolved by name when the config is joined to your handlers by constructing a Flow.
FlowConfig is a Pydantic model. It rejects unknown keys, and every model below does the same except Action, which passes extra keys through to its handler.
For a walkthrough of the format rather than a field list, see the Flow Configs guide.

Fields

str
required
Name of the node the flow starts in. Must be a key of nodes.
dict[str, FlowConfig.Node]
required
The flow’s nodes, keyed by name. At least one entry.
list[FlowConfig.Function]
default:"[]"
Tools offered at every node. Names must be unique among themselves and must not collide with any node’s functions.
dict[str, FlowConfig.Subflow]
default:"{}"
Subflows the flow’s nodes can run, keyed by flow id. See Subflows.

Loaders

from_file

Load a config from a .yaml, .yml, or .json file. A file with any suffix other than .json is parsed as YAML, and may use !include with paths relative to the file’s own directory. Included paths are not confined to that directory, so load only files you control.

from_yaml

Load a config from YAML text. base_dir is the directory !include paths resolve against; when it is omitted, !include is unavailable. An include can read any file the process can read, so omit base_dir for text from an untrusted source.

from_json

Load a config from JSON text.

model_validate

Pydantic’s own loader, for a dict that is already parsed.

Models

FlowConfig.Node

One node of the flow. Its key under nodes is its name.
list[FlowConfig.Message]
What the LLM should do at this node. Required unless the node runs a subflow with flow, in which case it must be empty.
str | None
default:"None"
The bot’s role or personality, sent as the LLM’s system instruction on entering this node. It persists across transitions until another node sets its own. May contain {{ key }} placeholders.
list[FlowConfig.Function]
default:"[]"
Tools offered at this node, in addition to the config’s global_functions. Names must be unique within the node.
list[FlowConfig.Action]
default:"[]"
Actions run before the LLM responds at this node.
list[FlowConfig.Action]
default:"[]"
Actions run after the LLM responds at this node.
"append" | "reset" | None
default:"None"
How the LLM context is updated on entering this node. Defaults to the FlowManager’s strategy. RESET_WITH_SUMMARY is not available here.
bool
default:"True"
Whether the LLM responds as soon as the node is entered.
dict[str, JsonValue] | None
default:"None"
JSON data the application attaches to the node, such as the id of the editor element it stands for. Flows never acts on it and never sends it to the LLM, but an RTVI client receives it when the node is entered, so keep anything the end user should not see out of it. A Flow copies it onto the NodeConfig it builds.
str | None
default:"None"
Id of the subflow this node runs, a key of the config’s flows. A node that runs a subflow takes only return_to and metadata besides; its other fields must be left at their defaults. See Subflows.
str | None
default:"None"
The node that return in the subflow leads to. May be omitted when the subflow never returns. Allowed only on a node that sets flow.

FlowConfig.Subflow

A set of nodes that a flow’s nodes can run. Its key under flows is its flow id.
str
required
Name of the node the subflow starts in. Must be a key of nodes.
dict[str, FlowConfig.Node]
required
The subflow’s nodes, keyed by name. At least one entry. No node may be named return, and node names cannot contain a dot.

FlowConfig.Message

One message in a node’s task_messages.
str
required
Message role, e.g. developer or system.
str
required
Message text. May contain {{ key }} placeholders.

FlowConfig.Function

A tool offered at a node, or globally.
str
required
The tool’s name, as the LLM sees it. For an ordinary entry, also the name of the direct function in the handlers.
bool
default:"False"
Whether the tool is defined here rather than in code. Such a tool takes no parameters, runs no code, and moves the conversation to transition_to when the LLM calls it. Requires description and a transition_to that names a node.
str | None
default:"None"
What the tool is for, for the LLM. Only a transition_only entry has one; a direct function describes itself in its docstring, and setting this on an ordinary entry is a validation error.
str | FlowConfig.Branch | None
default:"None"
Node to transition to after the tool completes, or a branch table. Omitted for tools that stay on the current node.
dict[str, JsonValue] | None
default:"None"
JSON data the application attaches to the tool. Flows never acts on it and never sends it to the LLM, but an RTVI client receives it when a call to the tool moves the flow to a new node, so keep anything the end user should not see out of it. A Flow copies it onto the FlowsFunctionSchema it builds.

FlowConfig.Branch

A transition chosen by a field of the tool’s result.
str
required
Key of the tool’s result whose value selects the case. If the result is not a mapping, or has no such key, the call raises FlowError.
dict[str, str]
required
Result value to node name. At least one entry. Keys may be written as strings, booleans, or numbers; they are matched against the result value by its canonical string, so true: matches a result of Python True.
str | None
default:"None"
Node to transition to when the value matches no case. When omitted, an unmatched value stays on the current node.

FlowConfig.Action

A pre- or post-action on a node. Unlike the other models, this one allows extra keys, which pass through to the handler on the action dict.
str
required
Action type identifier. The built-in types are tts_say, end_conversation, and function.
str | None
default:"None"
Name of the handler in the handlers the Flow is constructed with. Required for function, optional for a custom type, and not allowed on tts_say or end_conversation.
A custom type with no handler must be registered in code with FlowManager.register_action.

Subflows

A set of nodes used by several flows, or several times in one, is written once under flows and run by any node that names it as its flow:
  • Entering a node that runs a subflow enters the subflow at its initial_node.
  • Inside a subflow, a transition_to names one of the subflow’s own nodes, or is return, which leads to the return_to of the node running it. To return to two places, run the subflow from two nodes.
  • A subflow’s nodes cannot run subflows, and global_functions are offered at them too.
  • A Flow builds a subflow’s nodes once for each node that runs it, named <node>.<subflow node>. FlowManager.current_node reports that name, and on_node_entered gives the node that runs the subflow as parent. Because of this, a config that has subflows cannot have a dot in a node name.

Placeholders

Prompt text may refer to the manager’s state with {{ key }} placeholders: a node’s role_message, the content of its task_messages, and the text of a tts_say action. FlowManager fills them from flow_manager.state each time it enters the node, so a value stored by a handler earlier in the conversation can appear in a later prompt.
  • {{ order.size }} walks into a stored mapping.
  • Values are rendered with str().
  • A key that is not in state raises FlowError when the node is entered.
  • To show the LLM a literal {{ key }}, escape it as \{{ key }}.

Validation

Loading validates the config’s structure. A failure raises a Pydantic ValidationError.
  • The top level is a mapping.
  • initial_node names a defined node.
  • Every transition_to, including every case and default of a branch, names a defined node. Inside a subflow, a target may also be return; see Subflows.
  • Function names are unique within a node and within global_functions, and a node’s function name does not collide with a global one.
  • A transition_only entry has a description and a transition_to that is a plain node name.
  • An ordinary entry has no description.
  • A function action has a handler; tts_say and end_conversation do not.
  • A node has task_messages, or runs a flow that is a key of flows. A node that runs a flow takes only flow, return_to, and metadata, and return_to applies only to such a node.
  • Inside a subflow, every transition_to names one of the subflow’s own nodes or is return; a subflow’s nodes do not run subflows.
  • A return_to names a defined node, and is required when the subflow it runs has a function that transitions to return.
  • Every subflow is run by at least one node, and a subflow’s function names do not collide with a global one.
  • A config with subflows has no dot in any node name.
References into your code are checked separately, when the Flow is constructed.

Schema

The format’s JSON Schema is published in the Pipecat repository at src/pipecat/flows/flow_config.schema.json, for editors and other tools to vendor.