How it works
When an agent has one or more deferred tools, the SDK changes what the model sees:- Deferred tool schemas are not included in the request’s
toolslist. - A single meta-tool,
ToolSearch, is automatically added so the agent can discover and activate deferred tools. - The system instruction gains a
## Deferred Toolssection listing each deferred tool’s name and description (but not its full schema), so the model knows what exists. - When the agent calls
ToolSearchto activate a tool, that tool’s full schema is appended to the request on subsequent turns and the agent can call it normally.
The
ToolSearch tool is injected automatically whenever at least one deferred tool is present. You do not register it yourself.Marking a function tool as deferred
A tool is deferred when itsagents.BaseTool has Deferred: true. Everything else about the tool stays the same.
hastekit.NewTool helper instead, mark it deferred with the hastekit.WithDeferred option:
ToolSearch for you:
Marking MCP tools as deferred
For MCP servers, pass the tool names you want deferred tomcpclient.WithDeferredTools. This is especially useful for servers that expose a large number of tools.
The ToolSearch tool
ToolSearch accepts two arguments:
When the agent activates a tool, the activation is recorded in the run state (
activated_deferred_tools), so the tool’s schema stays available for the remainder of the run.
When to defer a tool
- Large catalogs — once you get past ~20 tools, schemas start crowding the prompt and hurting tool-call accuracy.
- Specialty tools — tools that only matter in narrow cases (e.g. an issue-transition tool that’s only relevant once the user mentions tickets).
- Heavy schemas — tools with deeply nested inputs or long enums cost the most tokens to keep loaded.
When not to defer
- Always-needed tools — if the agent uses a tool on most runs, deferring just adds a round-trip every time.
- Tools the agent should consider proactively — discovery only happens when the agent thinks to search. If it doesn’t know a tool exists, it won’t look for it.
Deferral and approval are independent
Deferred and RequiresApproval are separate flags. A tool can be deferred (kept out of the prompt), approval-gated (held for human review when called), both, or neither.