Overview
AFlowConfig 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.
Fields
Tools offered at every node. Names must be unique among themselves and must
not collide with any node’s
functions.Subflows the flow’s nodes can run, keyed by flow id. See
Subflows.
Loaders
from_file
.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
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
model_validate
Models
FlowConfig.Node
One node of the flow. Its key undernodes is its name.
What the LLM should do at this node. Required unless the node runs a subflow
with
flow, in which case it must be empty.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.Tools offered at this node, in addition to the config’s
global_functions.
Names must be unique within the node.How the LLM context is updated on entering this node. Defaults to the
FlowManager’s strategy. RESET_WITH_SUMMARY is not available here.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.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.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 underflows is its flow id.
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’stask_messages.
FlowConfig.Function
A tool offered at a node, or globally.The tool’s name, as the LLM sees it. For an ordinary entry, also the name of
the direct function in the handlers.
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.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.Node to transition to after the tool completes, or a branch table. Omitted for
tools that stay on the current node.
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.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.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.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 theaction dict.
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.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 underflows 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_tonames one of the subflow’s own nodes, or isreturn, which leads to thereturn_toof the node running it. To return to two places, run the subflow from two nodes. - A subflow’s nodes cannot run subflows, and
global_functionsare offered at them too. - A
Flowbuilds a subflow’s nodes once for each node that runs it, named<node>.<subflow node>.FlowManager.current_nodereports that name, andon_node_enteredgives the node that runs the subflow asparent. 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
FlowErrorwhen 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 PydanticValidationError.
- The top level is a mapping.
initial_nodenames 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 bereturn; 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_onlyentry has adescriptionand atransition_tothat is a plain node name. - An ordinary entry has no
description. - A
functionaction has ahandler;tts_sayandend_conversationdo not. - A node has
task_messages, or runs aflowthat is a key offlows. A node that runs a flow takes onlyflow,return_to, andmetadata, andreturn_toapplies only to such a node. - Inside a subflow, every
transition_tonames one of the subflow’s own nodes or isreturn; a subflow’s nodes do not run subflows. - A
return_tonames a defined node, and is required when the subflow it runs has a function that transitions toreturn. - 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.
Flow is constructed.
Schema
The format’s JSON Schema is published in the Pipecat repository atsrc/pipecat/flows/flow_config.schema.json, for editors and other tools to vendor.