Register tools
At creation — pass tools directly or via a registry:
Built-in tools live under
pkg/tools/ (calculator, weather, search, and others).
Custom tools
Implementinterfaces.Tool. All five methods are required:
Complete implementation
Tool arguments from the LLM arrive as
map[string]any. JSON numbers decode as float64 — cast accordingly (see limit above).schema helpers
pkg/tools provides type-safe helpers for Parameters():
Optional tool interfaces
Tool execution context
The agent runtime sets aToolExecMeta value on the context.Context passed to Execute. Use it to access a stable idempotency key, the run ID, and other per-invocation metadata:
ToolExecMetaFromContext returns false only when Execute is called outside the agent runtime (e.g. in unit tests that invoke it directly).
When the model returns multiple tool calls in one turn, the SDK runs them in parallel by default:
How tools merge at run time
EachRun or Stream resolves the full tool list from all registered sources:
- Native / custom tools in
ToolRegistry - MCP tools (MCP)
- A2A skills (A2A)
- Sub-agent delegation tools (Sub-agents)
- Retriever tools when mode is agentic or hybrid (Retrieval)
save_memorywhen memory store mode is on-demand (Memory)
NewAgent and on each run.
MCP tool names are prefixed as
mcp_<serverKey>_<toolName> and A2A skills as a2a_<server>_<skillId>. This prevents collisions when multiple servers expose tools with the same logical name.Examples
Tools
Built-in, approval, authorizer, custom, and dynamic registry
Related
Approvals
Require human approval before tool execution
MCP
External tools via Model Context Protocol