(
toolUseBlocks: Array<{ name: string }>,
toolChoice: any,
forcedTools: string[],
usedForcedTools: string[]
)
| 45 | } |
| 46 | |
| 47 | export function checkForForcedToolUsage( |
| 48 | toolUseBlocks: Array<{ name: string }>, |
| 49 | toolChoice: any, |
| 50 | forcedTools: string[], |
| 51 | usedForcedTools: string[] |
| 52 | ): { hasUsedForcedTool: boolean; usedForcedTools: string[] } | null { |
| 53 | if (typeof toolChoice === 'object' && toolChoice !== null && toolUseBlocks.length > 0) { |
| 54 | const adaptedToolCalls = toolUseBlocks.map((tool) => ({ name: tool.name })) |
| 55 | const adaptedToolChoice = toolChoice.tool |
| 56 | ? { function: { name: toolChoice.tool.name } } |
| 57 | : toolChoice |
| 58 | |
| 59 | return trackForcedToolUsage( |
| 60 | adaptedToolCalls, |
| 61 | adaptedToolChoice, |
| 62 | logger, |
| 63 | 'bedrock', |
| 64 | forcedTools, |
| 65 | usedForcedTools |
| 66 | ) |
| 67 | } |
| 68 | return null |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Generates a unique tool use ID for Bedrock. |
no test coverage detected