Documentation Index
Fetch the complete documentation index at: https://docs.pipecat.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
LLMWorker extends PipelineWorker with an LLM pipeline and automatic tool registration. Pass an LLMService to the constructor and define tools with the @tool decorator. Decorated methods are registered as direct functions on the LLM and tracked so frames queued during tool execution can be deferred until all tools complete.
Configuration
Unique name for this agent.
The LLM service.
@tool decorated methods are automatically registered on it.Optional pipeline override. When
None, defaults to Pipeline([llm]).
Subclasses can pass a custom pipeline that wraps the LLM with additional
processors.Whether the agent starts active. Defaults to
False, since LLM agents
typically wait to be activated.Bridge configuration forwarded to
PipelineWorker. Pass () to wrap the LLM
pipeline with bus edge processors so it can exchange frames with another
bridged agent. See
PipelineWorker
for details.Whether to defer frames queued during tool execution until all tools complete.
When
True, any frames queued via queue_frame() while a @tool method is
running are held in an internal queue and delivered automatically once the
last tool finishes.Properties
Inherits all properties fromPipelineWorker.
llm
tool_call_active
True when one or more @tool methods are executing.
Methods
build_tools
@tool. Override to provide additional or different tools.
Returns: List of tool functions.
on_activated
@tool methods are set on the LLM. When args contains messages, they are appended to the LLM context. When args contains run_llm (defaults to True when messages are set), the LLM is triggered after appending.
| Parameter | Type | Description |
|---|---|---|
args | dict | None | Activation arguments (see LLMWorkerActivationArgs) |
activate_worker
@tool handler, pass params.result_callback to ensure any pending LLM output is fully delivered before the target is activated. To hand off (deactivate this agent and activate the target), pass deactivate_self=True.
| Parameter | Type | Default | Description |
|---|---|---|---|
worker_name | str | Name of the agent to activate | |
args | WorkerActivationArgs | None | None | Arguments forwarded to on_activated |
deactivate_self | bool | False | Whether to deactivate this agent before activating the target |
messages | list | None | None | LLM messages to inject and speak before activating |
result_callback | FunctionCallResultCallback | None | None | The result_callback from FunctionCallParams |
end
@tool handler, pass params.result_callback to ensure any pending LLM output is fully delivered before ending.
| Parameter | Type | Default | Description |
|---|---|---|---|
reason | str | None | None | Human-readable reason for ending |
messages | list | None | None | LLM messages to inject and speak before ending |
result_callback | FunctionCallResultCallback | None | None | The result_callback from FunctionCallParams |
queue_frame
| Parameter | Type | Default | Description |
|---|---|---|---|
frame | Frame | The frame to queue | |
direction | FrameDirection | DOWNSTREAM | Direction the frame should travel |
process_deferred_tool_frames
| Parameter | Type | Description |
|---|---|---|
frames | list[tuple[Frame, FrameDirection]] | The deferred frames collected during tool execution |
Decorators
@tool
Mark anLLMWorker method as an LLM tool. Decorated methods are automatically registered with the LLM and included in build_tools().
Parameters
Whether to cancel this tool call when an interruption occurs.
Timeout in seconds for this tool call. Defaults to
None (uses the LLM
service default).Method signature
Tool methods receive the LLM function call parameters object as their first argument (afterself), followed by the tool’s declared parameters:
Tool methods must call
params.result_callback() to return a result to the
LLM. The method signature (parameter names, types, and docstring) is
automatically used to generate the tool schema.