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:
CallContext
Inside a tool’s_arun(), use CallContext to read/write agent state:
LlmAgent automatically calls inject_context() on any tool that exposes it before each tool execution.
Filesystem tools
Sandboxed file operations restricted to a configurable workspace directory. All paths are validated to prevent escaping the workspace.| Tool | Description |
|---|---|
ls | List files and directories |
read_file | Read file contents (returns base64 for images) |
write_file | Write content to a file, creating parents as needed |
edit_file | Replace the first occurrence of old with new |
mkdir | Create a directory and parents |
glob | Find files matching a glob pattern (e.g. **/*.py) |
grep | Search file contents for a text pattern |
filesystem builtin:
Shell tools
Sandboxed shell execution with timeout, output truncation, and command filtering.| Tool | Description |
|---|---|
shell_exec | Run a command and return stdout + stderr |
shell_exec_background | Start a command in the background, return PID |
| Variable | Default | Description |
|---|---|---|
AGENT_WORKSPACE | /tmp/agent-workspace | Working directory |
AGENT_SHELL_TIMEOUT | 30 | Max seconds per command |
AGENT_SHELL_MAX_OUTPUT | 102400 | Output truncation limit (bytes) |
shell builtin: