Skip to main content

@tool

Mark an agent method as an LLM tool. On LLMAgent subclasses, decorated methods are automatically registered with the LLM and included in build_tools(). On FlowsAgent subclasses, decorated methods are automatically collected as global functions available at every flow node.
Can be used with or without arguments:

Parameters

bool
default:"True"
Whether to cancel this tool call when an interruption occurs. Only applies to LLMAgent tools.
float | None
default:"None"
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 (after self), 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.

@task

Mark an agent method as a task handler. Decorated methods are automatically collected by BaseAgent at initialization and dispatched when matching task requests arrive. Each request runs in its own asyncio task so the bus message loop is never blocked.
The decorator requires a name argument:

Parameters

str
required
Task name to match. The handler only receives requests with a matching name.
bool
default:"False"
When True, requests with this name run one at a time in FIFO order. Concurrent requests wait for the previous one to finish before running. When False (the default), multiple requests run concurrently. The wait time counts against the requester’s timeout, so a slow predecessor can cause queued requests to time out before they start.

Method Signature

Task handler methods receive a BusTaskRequestMessage:

@agent_ready

Mark a method as a handler for a specific agent becoming ready. Decorated methods are automatically collected by BaseAgent at initialization. When on_ready fires, the agent calls watch_agent for each decorated handler. When the watched agent registers, the decorated method is called.

Parameters

str
required
The name of the agent to watch.

Method Signature

Agent-ready handler methods receive an AgentReadyData instance: