Function tools
Wrap any async function as a LangChainBaseTool:
@tool decorator directly - both work with LlmAgent.
AgentTool - sub-agents as tools
Wrap aBaseAgent so it can be called as a tool by a parent agent:
ctx.event_callback - each event carries a branch field (e.g. "ResearchAgent") for attribution.
AgentTool callbacks
Hook into the child agent’s event stream withbefore_agent_callback (intercept each event, optionally short-circuit) and after_agent_callback (run after completion):
Transfer tool - explicit agent handoff
Exit loop tool
Signal aLoopAgent to stop iterating:
ToolContext
Inside a tool’s_arun(), use ToolContext to read/write agent state:
LlmAgent automatically calls inject_context() on any tool that exposes it before each tool execution.