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

Function checkForForcedToolUsage

apps/sim/providers/anthropic/utils.ts:60–85  ·  view source on GitHub ↗
(
  response: any,
  toolChoice: any,
  forcedTools: string[],
  usedForcedTools: string[]
)

Source from the content-addressed store, hash-verified

58}
59
60export function checkForForcedToolUsage(
61 response: any,
62 toolChoice: any,
63 forcedTools: string[],
64 usedForcedTools: string[]
65): { hasUsedForcedTool: boolean; usedForcedTools: string[] } | null {
66 if (typeof toolChoice === 'object' && toolChoice !== null && Array.isArray(response.content)) {
67 const toolUses = response.content.filter((item: any) => item.type === 'tool_use')
68
69 if (toolUses.length > 0) {
70 const adaptedToolCalls = toolUses.map((tool: any) => ({ name: tool.name }))
71 const adaptedToolChoice =
72 toolChoice.type === 'tool' ? { function: { name: toolChoice.name } } : toolChoice
73
74 return trackForcedToolUsage(
75 adaptedToolCalls,
76 adaptedToolChoice,
77 logger,
78 'anthropic',
79 forcedTools,
80 usedForcedTools
81 )
82 }
83 }
84 return null
85}

Callers 1

Calls 1

trackForcedToolUsageFunction · 0.90

Tested by

no test coverage detected