MCPcopy Create free account
hub / github.com/Noumena-Network/code / getToolSearchMode

Function getToolSearchMode

src/utils/toolSearch.ts:174–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172 * (unset) tst (default: always defer MCP and shouldDefer tools)
173 */
174export function getToolSearchMode(): ToolSearchMode {
175 // CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS is a kill switch for beta API
176 // features. Tool search emits defer_loading on tool definitions and
177 // tool_reference content blocks — both require the API to accept a beta
178 // header. When the kill switch is set, force 'standard' so no beta shapes
179 // reach the wire, even if ENABLE_TOOL_SEARCH is also set. This is the
180 // explicit escape hatch for proxy gateways that the heuristic in
181 // isToolSearchEnabledOptimistic doesn't cover.
182 // upstream issue context in source history
183 if (isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)) {
184 return 'standard'
185 }
186
187 const value = process.env.ENABLE_TOOL_SEARCH
188
189 // Handle auto:N syntax - check edge cases first
190 const autoPercent = value ? parseAutoPercentage(value) : null
191 if (autoPercent === 0) return 'tst' // auto:0 = always enabled
192 if (autoPercent === 100) return 'standard'
193 if (isAutoToolSearchMode(value)) {
194 return 'tst-auto' // auto or auto:1-99
195 }
196
197 if (isEnvTruthy(value)) return 'tst'
198 if (isEnvDefinedFalsy(process.env.ENABLE_TOOL_SEARCH)) return 'standard'
199 return 'tst' // default: always defer MCP and shouldDefer tools
200}
201
202/**
203 * Default patterns for models that do NOT support tool_reference.

Callers 2

isToolSearchEnabledFunction · 0.85

Calls 4

isEnvTruthyFunction · 0.90
parseAutoPercentageFunction · 0.85
isAutoToolSearchModeFunction · 0.85
isEnvDefinedFalsyFunction · 0.85

Tested by

no test coverage detected