Overview
BaseAgent is the abstract base class that all agents inherit from. It handles agent lifecycle, parent-child relationships, bus communication, and task coordination.
Agents that return a pipeline from build_pipeline() run a Pipecat pipeline. Agents that don’t override build_pipeline() operate purely through bus messages (e.g. coordinators, orchestrators).
Configuration
str
required
Unique name for this agent. Used for bus message routing and registry lookup.
bool
default:"True"
Whether the agent starts active. When
False, the agent waits for an
activate_agent() call before on_activated fires.tuple[str, ...] | None
default:"None"
Bridge configuration for receiving pipeline frames from the bus.
None means
not bridged. An empty tuple () means bridged, accepting frames from all
bridges. A tuple of names like ("voice",) means bridged, accepting only
frames from those bridges.tuple[type[Frame], ...] | None
default:"None"
Frame types to exclude from bus forwarding when bridged. Lifecycle frames
(
StartFrame, EndFrame, CancelFrame, StopFrame) are always excluded.Properties
bus
active
activation_args
None if the agent is inactive. The value is cleared when the agent is deactivated.
parent
None if this is a root agent.
registry
bridged
ready
started_at
None if not yet started.
children
add_agent().
pipeline_task
PipelineTask for this agent. Raises RuntimeError if the pipeline task has not been created yet.
task_id
None if idle.
task_groups
task_id.
Lifecycle Hooks
Override these methods to react to lifecycle events. Always callsuper() when overriding.
on_ready
on_finished
on_error
send_error(), fail a running task, or log and recover).
on_activated
on_deactivated
on_agent_ready
watch_agent(). For child agents it fires only on the parent.
on_agent_error
Agent Management
add_agent
activate_agent
on_activated hook will be called with the provided arguments.
deactivate_agent
on_deactivated hook will be called.
handoff_to
activate_agent() and deactivate_agent() directly.
watch_agent
on_agent_ready fires immediately. Otherwise it fires when the agent eventually registers.
end
cancel
Task Coordination
request_task
on_task_response, on_task_completed) or task() for that.
Returns: The generated
task_id.
task
async for inside the block to receive intermediate events.
Returns: A
TaskContext to use with async with.
request_task_group
Returns: The generated
task_id shared by all agents in the group.
task_group
async for inside the block to receive intermediate events.
Returns: A
TaskGroupContext to use with async with.
cancel_task
request_task_update
send_task_response
send_task_update
send_task_stream_start
send_task_stream_data
send_task_stream_end
Task Hooks
Override these methods to handle task events. Always callsuper() when overriding.
on_task_request
send_task_update() to report progress and send_task_response() to return results.
on_task_response
on_task_update
on_task_update_requested
send_task_update().
on_task_completed
on_task_error
ERROR or FAILED status and cancel_on_error is set.
on_task_stream_start
on_task_stream_data
on_task_stream_end
on_task_cancelled
Pipeline
build_pipeline
create_pipeline
build_pipeline_task
PipelineTask for this agent’s pipeline. Override to customize task parameters (e.g. enable interruptions).