Skip to main content

What is FlowsAgent?

FlowsAgent integrates Pipecat Flows into the subagents framework. It provides structured, node-based conversations where each node defines what the agent says, what functions are available, and where the conversation goes next. Use FlowsAgent when you need deterministic conversation paths — like booking flows, intake forms, or multi-step processes — that would be hard to control with a free-form LLM prompt. You can have multiple FlowsAgent instances in the same system, each with its own conversation paths, and hand off between them or combine them with LLMAgent for free-form sections.

Creating a FlowsAgent

Subclass FlowsAgent and implement three methods:
FlowsAgent requires a context_aggregator parameter. Pass the same LLMContextAggregatorPair instance that your main agent uses, so the flows agent can share conversation context.

Defining node functions

Node functions are async methods that receive a FlowManager and any parameters the LLM extracted. They return a tuple of (result, next_node):
Each node defines:
  • name — an identifier for the node
  • task_messages — messages injected when entering the node (guide the LLM)
  • functions — which functions are available at this node
The LLM collects user input and calls the appropriate function. The function processes the input and returns the next node, creating a directed conversation flow.

Conditional branching

Node functions can return different next nodes based on results:

Ending the flow

Use post_actions with "end_conversation" to end the flow:

Mixing with LLM agents

A common pattern is combining a FlowsAgent with an LLMAgent router. The router handles free-form conversation and transfers to the flows agent when structured input is needed:
The main agent creates both and adds them as children:

Resuming flows

When a FlowsAgent is reactivated (for example, after being handed off and then handed back), it resumes from build_resume_node() instead of build_initial_node():
Override this to control where the flow resumes.

Global tools

You can add tools that are available at every node using the @tool decorator:
Tools decorated with @tool on a FlowsAgent are available at every node, regardless of the node’s functions list. This is useful for escape hatches like transferring to another agent.
Install the Flows extra to use FlowsAgent: