@tool
Mark an agent method as an LLM tool. OnLLMAgent 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.
Parameters
Whether to cancel this tool call when an interruption occurs. Only applies to
LLMAgent tools.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.@task
Mark an agent method as a task handler. Decorated methods are automatically collected byBaseAgent at initialization and dispatched when matching task requests arrive.
Parameters
Task name to match. When set, this handler only receives requests with a
matching name. When
None, handles all unnamed requests (or requests with no
matching named handler).When
True, each request runs in a separate asyncio task for concurrent
execution.Method Signature
Task handler methods receive aBusTaskRequestMessage:
@agent_ready
Mark a method as a handler for a specific agent becoming ready. Decorated methods are automatically collected byBaseAgent 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
The name of the agent to watch.
Method Signature
Agent-ready handler methods receive anAgentReadyData instance: