Skip to main content

normalize_tool_call_id

Function normalize_tool_call_id 

Source
pub fn normalize_tool_call_id(id: &str) -> String
Expand description

Normalize a tool call ID for cross-provider compatibility.

OpenAI Responses API generates IDs that are 450+ chars with special characters like |. Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars).

This replaces non-alphanumeric (except _ and -) chars with _ and truncates to 64 characters.