Looking for specific tool implementations?This reference covers the tool system architecture and how to build custom tools. For documentation on built-in tools, see the Tools Guide:
- Coding Tools — Shell execution, file editing
- Filesystem Tools — Read, search, glob, list
- Memory Tools — Persistent storage
- Computer Tools — Mouse, keyboard, screenshots
- Web Tools — Browser automation
How Tools Work
HUD tools are async functions that:- Receive structured input from agents (via MCP or native APIs)
- Execute actions against an environment, filesystem, or service
- Return
ContentBlocklists — standardized MCP output (text, images, etc.)
bash, it uses Anthropic’s native bash_20250124 API. When OpenAI calls shell, it uses their native format. HUD translates automatically.
BaseTool
All tools inherit fromBaseTool. Implement __call__ to define behavior.
| Parameter | Type | Description | Default |
|---|---|---|---|
env | Any | Stateful context (executor, browser, etc.) | None |
name | str | Tool name for MCP registration | Auto from class |
title | str | Human-readable display name | Auto from class |
description | str | Tool description for agents | Auto from docstring |
mcp— FastMCPFunctionToolwrapper for server registrationnative_specs— Dict mappingAgentTypetoNativeToolSpec
Native Tool Specs
Tools can declare native API mappings for specific providers. This enables zero-translation tool calls for supported agents.| Field | Type | Description |
|---|---|---|
api_type | str | Provider’s tool type identifier |
api_name | str | Provider’s tool name |
beta | str | None | Required beta header (Anthropic) |
role | str | None | Logical role for exclusion ("shell", "editor", "memory") |
supported_models | list[str] | None | Glob patterns for compatible models |
role are mutually exclusive — you can’t have both BashTool (Claude) and ShellTool (OpenAI) active. When an agent accepts one natively, others with the same role are excluded.
Tool Hooks
Modify tool behavior without subclassing using@tool.before and @tool.after:
@tool.before:
- Receives all tool arguments as kwargs
- Return
dictto modify arguments before execution - Return
Noneto proceed unchanged - Raise exception to block execution
@tool.after:
- Receives tool arguments plus
result=(the return value) - Return modified result to change output
- Return
Noneto keep original result
Common Types
ContentBlock
MCP standard output format. Tools returnlist[ContentBlock].
ContentResult
Helper for building tool outputs with multiple content types:ToolError
Raise to return an error to the agent:ToolError messages are returned to the agent as text content, not raised as exceptions.
EvaluationResult
For evaluation/scoring tools:BaseHub
Organize related tools into namespaced groups with a dispatcher pattern:- Internal tools are hidden from MCP clients
- Single dispatcher endpoint for all hub tools
- Automatic resource catalog generation
AgentTool
Wrap a scenario as a callable tool for hierarchical agent systems:| Parameter | Type | Description |
|---|---|---|
task | Task | Task template from env("scenario") |
model | str | Model for subagent (via gateway) |
agent | type[MCPAgent] | Custom agent class (alternative to model) |
name | str | Tool name for orchestrator |
description | str | Tool description |
| None = None are hidden from the orchestrator but available for evaluation scoring:
Executors
Executors provide platform-specific implementations for computer control tools.BaseExecutor
Abstract base for all executors:Built-in Executors
| Executor | Platform | Features |
|---|---|---|
PyAutoGUIExecutor | Cross-platform | Real mouse/keyboard, screenshots |
XDOExecutor | Linux/X11 | Native X11, faster on Linux |
Callback Functions
Monitor and hook into tool actions:async def.
Complete Example
Custom database tool with validation and logging:See Also
- Tools Guide — Built-in tool implementations
- Environments — Adding tools to environments
- Agents — How agents use tools