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

Function buildSchemaNotSentHint

src/services/tools/toolExecution.ts:579–598  ·  view source on GitHub ↗
(
  tool: Tool,
  messages: Message[],
  tools: readonly { name: string }[],
)

Source from the content-addressed store, hash-verified

577 * model to re-load the tool; this hint does. Null if the schema was sent.
578 */
579export function buildSchemaNotSentHint(
580 tool: Tool,
581 messages: Message[],
582 tools: readonly { name: string }[],
583): string | null {
584 // Optimistic gating — reconstructing claude.ts's full useToolSearch
585 // computation is fragile. These two gates prevent pointing at a ToolSearch
586 // that isn't callable; occasional misfires (Haiku, tst-auto below threshold)
587 // cost one extra round-trip on an already-failing path.
588 if (!isToolSearchEnabledOptimistic()) return null
589 if (!isToolSearchToolAvailable(tools)) return null
590 if (!isDeferredTool(tool)) return null
591 const discovered = extractDiscoveredToolNames(messages)
592 if (discovered.has(tool.name)) return null
593 return (
594 `\n\nThis tool's schema was not sent to the API — it was not in the discovered-tool set derived from message history. ` +
595 `Without the schema in your prompt, typed parameters (arrays, numbers, booleans) get emitted as strings and the client-side parser rejects them. ` +
596 `Load the tool first: call ${TOOL_SEARCH_TOOL_NAME} with query "select:${tool.name}", then retry this call.`
597 )
598}
599
600async function checkPermissionsAndCallTool(
601 tool: Tool,

Callers 1

Calls 5

isDeferredToolFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected