Register tools
At creation — pass tools directly or via a registry:| Option | When to use |
|---|---|
WithTools | Fixed tool set known at startup |
WithToolRegistry | Add or remove tools after NewAgent — see Dynamic Capabilities |
pkg/tools/ (calculator, weather, search, and others).
Custom tools
Implementinterfaces.Tool. All five methods are required:
| Method | Purpose |
|---|---|
Name() string | Stable identifier the LLM uses in tool calls — must be unique across all tool sources |
DisplayName() string | Human-readable label for UI and logs |
Description() string | When and how the model should use this tool — quality here affects routing accuracy |
Parameters() JSONSchema | JSON Schema for tool arguments — build with pkg/tools helpers |
Execute(ctx, args) (any, error) | Run the tool and return a result |
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():
| Helper | JSON type |
|---|---|
tools.ParamString(desc) | "string" |
tools.ParamInteger(desc) | "integer" |
tools.ParamNumber(desc) | "number" |
tools.ParamBool(desc) | "boolean" |
tools.ParamEnum(desc, vals...) | "string" with "enum" |
tools.ParamArray(desc, items) | "array" |
tools.Params(properties, required...) | Full "object" schema |
Optional tool interfaces
| Interface | Purpose |
|---|---|
ToolApproval | Tool-level hint for interactive human approval — overridden by the agent’s WithToolApprovalPolicy |
ToolAuthorizer | Programmatic gate (scopes, tenancy, feature flags) before approval or execution |
Tool execution mode
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, Stream, or RunAsync 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
Dynamic Capabilities
Register and unregister tools at runtime
Configuration
WithTools, WithToolRegistry, WithAgentToolExecutionMode