MCPcopy Index your code
hub / github.com/simstudioai/sim / checkForForcedToolUsage

Function checkForForcedToolUsage

apps/sim/providers/google/utils.ts:365–403  ·  view source on GitHub ↗
(
  functionCalls: FunctionCall[] | undefined,
  toolConfig: ToolConfig | undefined,
  forcedTools: string[],
  usedForcedTools: string[]
)

Source from the content-addressed store, hash-verified

363 * Checks for forced tool usage in Google Gemini responses
364 */
365export function checkForForcedToolUsage(
366 functionCalls: FunctionCall[] | undefined,
367 toolConfig: ToolConfig | undefined,
368 forcedTools: string[],
369 usedForcedTools: string[]
370): ForcedToolResult | null {
371 if (!functionCalls?.length) return null
372
373 const adaptedToolCalls = functionCalls.map((fc) => ({
374 name: fc.name ?? '',
375 arguments: (fc.args ?? {}) as Record<string, unknown>,
376 }))
377
378 const result = trackForcedToolUsage(
379 adaptedToolCalls,
380 toolConfig,
381 logger,
382 'google',
383 forcedTools,
384 usedForcedTools
385 )
386
387 if (!result) return null
388
389 const nextToolConfig: ToolConfig | undefined = result.nextToolConfig?.functionCallingConfig?.mode
390 ? {
391 functionCallingConfig: {
392 mode: mapToFunctionCallingMode(result.nextToolConfig.functionCallingConfig.mode),
393 allowedFunctionNames: result.nextToolConfig.functionCallingConfig.allowedFunctionNames,
394 },
395 }
396 : undefined
397
398 return {
399 hasUsedForcedTool: result.hasUsedForcedTool,
400 usedForcedTools: result.usedForcedTools,
401 nextToolConfig,
402 }
403}

Callers 1

executeToolCallsBatchFunction · 0.90

Calls 2

trackForcedToolUsageFunction · 0.90
mapToFunctionCallingModeFunction · 0.85

Tested by

no test coverage detected