Skip to main content

LLMAgent overview

LLMAgent extends BaseAgent with everything you need to run an LLM-powered agent:
  • A pipeline with your LLM service, automatically built
  • Tool registration via the @tool decorator
  • Activation handling that injects messages and runs the LLM
To create an LLM agent, subclass LLMAgent and implement build_llm():
The default pipeline is: LLM (with tools from build_tools() automatically registered). When bridged=() is set, the framework wraps this pipeline with edge processors that connect it to the bus.

The @tool decorator

The @tool decorator marks a method as an LLM-callable tool. The framework automatically collects all @tool-decorated methods and registers them with the LLM service.
The tool’s name comes from the method name. The docstring becomes the tool description. Parameter types and descriptions are extracted from the type annotations and the Args section in the docstring.

Tool options

The @tool decorator accepts options:

Tool parameters

Every tool method receives self and params: FunctionCallParams as the first two arguments. Additional arguments are the tool’s parameters that the LLM fills in. The params object gives you access to:
  • params.result_callback(result) — return the result to the LLM
  • params.llm — the LLM service instance, useful for queuing frames

Returning results

Always call params.result_callback() to return the tool result to the LLM:

Activation with messages

When an LLMAgent is activated, you can inject messages into its context:
The default on_activated() implementation:
  1. Sets the tools from build_tools()
  2. Injects the provided messages into the LLM context
  3. Runs the LLM if run_llm is True (the default)

Custom pipelines

If you need more control, you can override build_pipeline() entirely. For example, to add TTS to the agent’s own pipeline:
This is how custom voices per agent works — each agent adds its own TTS after the LLM.