Repair a tool call by trying case-insensitive matching. If the tool name doesn't match any known tool, try lowercase. If still no match, return "invalid" as the tool name.
(name: &str, tools: &HashMap<String, ToolDefinition>)
| 1329 | /// If the tool name doesn't match any known tool, try lowercase. |
| 1330 | /// If still no match, return "invalid" as the tool name. |
| 1331 | pub fn repair_tool_call(name: &str, tools: &HashMap<String, ToolDefinition>) -> String { |
| 1332 | // Exact match |
| 1333 | if tools.contains_key(name) { |
| 1334 | return name.to_string(); |
| 1335 | } |
| 1336 | |
| 1337 | // Try lowercase |
| 1338 | let lower = name.to_lowercase(); |
| 1339 | if lower != name && tools.contains_key(&lower) { |
| 1340 | tracing::info!( |
| 1341 | original = name, |
| 1342 | repaired = %lower, |
| 1343 | "Repairing tool call: case mismatch" |
| 1344 | ); |
| 1345 | return lower; |
| 1346 | } |
| 1347 | |
| 1348 | // No match - return "invalid" |
| 1349 | tracing::warn!(tool_name = name, "Unknown tool call, mapping to 'invalid'"); |
| 1350 | "invalid".to_string() |
| 1351 | } |
| 1352 | |
| 1353 | /// Inject a dummy tool for LiteLLM proxy compatibility. |
| 1354 | /// LiteLLM and some Anthropic proxies require the tools parameter to be present |
nothing calls this directly
no outgoing calls
no test coverage detected