tools array - which sends every tool to the model on every turn - toolsets are resolved at the start of each turn and can depend on context: the user’s role, feature flags, which phase the agent is in, and so on.
An agent can mix static tools and any number of toolsets. All are merged into a single flat tool list before each model call.
Toolset composition
FunctionToolset - basic toolset
FunctionToolset is the simplest toolset: a named group of static tools. Use it to logically bundle related tools together.
FilteredToolset - conditional tools
FilteredToolset wraps another toolset with a boolean predicate. When the predicate returns false, the entire inner toolset is hidden from the model for that turn.
PreparedToolset.
PreparedToolset - per-turn filtering
PreparedToolset lets you return a subset of tools based on context. The prepare function receives the full RunContext and the complete tool list, and returns whichever tools to expose.
PreparedToolset vs FilteredToolset:
FilteredToolset | PreparedToolset | |
|---|---|---|
| Granularity | All-or-nothing | Per-tool |
| Predicate receives | (ctx) | (ctx, tools) |
| Use when | Hiding entire toolset by role | Filtering individual tools by state |
CombinedToolset - merging toolsets
CombinedToolset merges multiple toolsets into one. Tools from later toolsets override earlier ones on name conflict (last name wins).
PrefixedToolset - namespacing
PrefixedToolset adds a string prefix to every tool name. Use it to avoid collisions when combining toolsets from different domains.
RenamedToolset - custom names
RenamedToolset renames specific tools using a mapping object.
WrapperToolset - middleware
WrapperToolset wraps another toolset and intercepts execute calls. Use it for cross-cutting concerns like logging, tracing, input transformation, or output transformation - without modifying the underlying tools.
ApprovalRequiredToolset - mark all for approval
ApprovalRequiredToolset wraps a toolset and marks every tool inside it as requiresApproval: true. Use it when you want to require human approval for an entire group of tools without modifying them individually.
ApprovalRequiredError with the deferred tool requests. See Human-in-the-Loop for the full approval flow.
ExternalToolset - tools without Zod schemas
ExternalToolset is for tools that have pre-existing JSON schemas - for example, tools loaded from an MCP server. Parameters are passed as raw JSON instead of going through Zod parsing.
ExternalToolset when integrating with external tool registries that provide their own JSON Schema definitions.