fix: sanitize tool call IDs for Azure OpenAI
Azure OpenAI enforces a 40-character limit on tool_calls[].id fields,
which causes HTTP 400 errors when tool call IDs exceed this limit.
Add Azure OpenAI detection (via provider name containing "azure") and
enable tool call ID sanitization for Azure providers.
This commit is contained in:
parent
5f4715acfc
commit
99f645a529
@ -73,6 +73,9 @@ export function resolveTranscriptPolicy(params: {
|
||||
const isGoogle = isGoogleModelApi(params.modelApi);
|
||||
const isAnthropic = isAnthropicApi(params.modelApi, provider);
|
||||
const isOpenAi = isOpenAiProvider(provider) || (!provider && isOpenAiApi(params.modelApi));
|
||||
// Azure OpenAI uses OpenAI-compatible APIs but has stricter limits (40 char tool call IDs).
|
||||
// Detect via provider name containing "azure".
|
||||
const isAzureOpenAi = isOpenAiApi(params.modelApi) && provider.includes("azure");
|
||||
const isMistral = isMistralModel({ provider, modelId });
|
||||
const isOpenRouterGemini =
|
||||
(provider === "openrouter" || provider === "opencode") &&
|
||||
@ -83,9 +86,9 @@ export function resolveTranscriptPolicy(params: {
|
||||
modelId,
|
||||
});
|
||||
|
||||
const needsNonImageSanitize = isGoogle || isAnthropic || isMistral || isOpenRouterGemini;
|
||||
const needsNonImageSanitize = isGoogle || isAnthropic || isMistral || isOpenRouterGemini || isAzureOpenAi;
|
||||
|
||||
const sanitizeToolCallIds = isGoogle || isMistral;
|
||||
const sanitizeToolCallIds = isGoogle || isMistral || isAzureOpenAi;
|
||||
const toolCallIdMode: ToolCallIdMode | undefined = isMistral
|
||||
? "strict9"
|
||||
: sanitizeToolCallIds
|
||||
|
||||
Loading…
Reference in New Issue
Block a user