@@ -948,6 +948,18 @@ type LargeToolOutputConfig struct {
948948 OutputDirectory string `json:"outputDir,omitempty"`
949949}
950950
951+ // ToolSearchConfig allows to configure tool search behavior.
952+ // Tool search defers tools to keep the model's active tool set small.
953+ // To override the tool-search tool's implementation, register a
954+ // [Tool] named "tool_search_tool" with OverridesBuiltInTool set to true.
955+ type ToolSearchConfig struct {
956+ // Controls whether tool search is enabled.
957+ Enabled * bool `json:"enabled,omitempty"`
958+ // DeferThreshold is the tool count above which MCP and external tools are
959+ // deferred behind tool search. When nil, the runtime default (30) applies.
960+ DeferThreshold * int `json:"deferThreshold,omitempty"`
961+ }
962+
951963// SessionFSCapabilities declares optional provider capabilities.
952964type SessionFSCapabilities struct {
953965 // Sqlite indicates whether the provider supports SQLite query/exists operations.
@@ -1153,6 +1165,10 @@ type SessionConfig struct {
11531165 // output exceeding the configured size, the output is written to a temp file
11541166 // and a reference is returned to the model instead of the full payload.
11551167 LargeOutput * LargeToolOutputConfig
1168+ // ToolSearch overrides the runtime's built-in tool-search behavior, which
1169+ // defers rarely used tools behind a searchable index. When nil, the runtime
1170+ // default applies.
1171+ ToolSearch * ToolSearchConfig
11561172 // Memory configures the memory feature for the session. When omitted, the
11571173 // runtime default applies.
11581174 Memory * MemoryConfiguration
@@ -1290,6 +1306,14 @@ type ToolInvocation struct {
12901306 ToolName string
12911307 Arguments any
12921308
1309+ // AvailableTools is a snapshot of the session's currently initialized
1310+ // tools. The SDK populates it only when this invocation targets the
1311+ // built-in tool-search tool ("tool_search_tool"), so a tool-search
1312+ // override can rank/filter the live catalog -- including MCP tools
1313+ // configured in settings -- without issuing its own RPC. It is nil for
1314+ // every other tool invocation.
1315+ AvailableTools []rpc.CurrentToolMetadata
1316+
12931317 // TraceContext carries the W3C Trace Context propagated from the CLI's
12941318 // execute_tool span. Pass this to OpenTelemetry-aware code so that
12951319 // child spans created inside the handler are parented to the CLI span.
@@ -1309,6 +1333,8 @@ type ToolResult struct {
13091333 Error string `json:"error,omitempty"`
13101334 SessionLog string `json:"sessionLog,omitempty"`
13111335 ToolTelemetry map [string ]any `json:"toolTelemetry,omitempty"`
1336+ // ToolReferences lists names of tools returned by a tool-search tool.
1337+ ToolReferences []string `json:"toolReferences,omitempty"`
13121338}
13131339
13141340// CommandContext provides context about a slash-command invocation.
@@ -1605,6 +1631,10 @@ type ResumeSessionConfig struct {
16051631 // output exceeding the configured size, the output is written to a temp file
16061632 // and a reference is returned to the model instead of the full payload.
16071633 LargeOutput * LargeToolOutputConfig
1634+ // ToolSearch overrides the runtime's built-in tool-search behavior, which
1635+ // defers rarely used tools behind a searchable index. When nil, the runtime
1636+ // default applies.
1637+ ToolSearch * ToolSearchConfig
16081638 // Memory configures the memory feature for the session. When omitted, the
16091639 // runtime default applies.
16101640 Memory * MemoryConfiguration
@@ -2125,6 +2155,7 @@ type createSessionRequest struct {
21252155 DisabledSkills []string `json:"disabledSkills,omitempty"`
21262156 InfiniteSessions * InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
21272157 LargeOutput * LargeToolOutputConfig `json:"largeOutput,omitempty"`
2158+ ToolSearch * ToolSearchConfig `json:"toolSearch,omitempty"`
21282159 Memory * MemoryConfiguration `json:"memory,omitempty"`
21292160 Commands []wireCommand `json:"commands,omitempty"`
21302161 RequestElicitation * bool `json:"requestElicitation,omitempty"`
@@ -2216,6 +2247,7 @@ type resumeSessionRequest struct {
22162247 DisabledSkills []string `json:"disabledSkills,omitempty"`
22172248 InfiniteSessions * InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
22182249 LargeOutput * LargeToolOutputConfig `json:"largeOutput,omitempty"`
2250+ ToolSearch * ToolSearchConfig `json:"toolSearch,omitempty"`
22192251 Memory * MemoryConfiguration `json:"memory,omitempty"`
22202252 Commands []wireCommand `json:"commands,omitempty"`
22212253 RequestElicitation * bool `json:"requestElicitation,omitempty"`
0 commit comments