#4057: fix: sanitize tool call IDs for Azure OpenAI
agents
Cluster:
Tool Call ID Sanitization
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.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates `resolveTranscriptPolicy` (`src/agents/transcript-policy.ts`) to detect “Azure OpenAI” providers and enable transcript/tool-call sanitization to avoid Azure’s 40-character `tool_calls[].id` limit.
The policy object returned here is consumed by the session history/message sanitizers (e.g. `sanitizeSessionMessagesImages`), so toggles like `sanitizeToolCallIds` and `toolCallIdMode` directly affect whether outbound requests have tool-call IDs rewritten into a stricter format.
<h3>Confidence Score: 2/5</h3>
- Not safe to merge as-is because the main intended behavior change appears not to take effect for Azure OpenAI.
- The PR adds an `isAzureOpenAi` flag and includes it in `sanitizeToolCallIds`/`needsNonImageSanitize`, but the returned policy still gates `sanitizeToolCallIds` behind `!isOpenAi`, so Azure (which uses OpenAI APIs) likely won’t have tool-call IDs sanitized and will continue to hit 400s. Azure detection logic is also heuristic and may miss real Azure configs depending on provider naming/normalization.
- src/agents/transcript-policy.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#12812: fix(transcript-policy): sanitize tool call IDs for all non-OpenAI p...
by justin-nevins · 2026-02-09
84.0%
#8117: Agents: sanitize tool call ids for OpenAI
by TylonHH · 2026-02-03
83.5%
#13831: fix(agents): include Anthropic in tool call ID sanitization
by lailoo · 2026-02-11
78.9%
#19094: Fix empty tool_call_id and function names in provider transcript pa...
by yxshee · 2026-02-17
78.7%
#12608: fix: sanitize client tool call IDs per provider requirements
by piyushhhxyz · 2026-02-09
78.4%
#3647: fix: sanitize tool arguments in session history
by nhangen · 2026-01-29
78.4%
#13976: fix(anthropic): include Anthropic in tool call ID sanitization
by omair445 · 2026-02-11
78.3%
#4700: fix: deduplicate tool_use IDs and enable sanitization for Anthropic
by marcelomar21 · 2026-01-30
78.3%
#21313: fix: repair orphaned OpenAI tool results in session history
by kelvinCB · 2026-02-19
77.6%
#18002: fix: add Azure AI Foundry URL support for custom providers
by MisterGuy420 · 2026-02-16
76.6%