← Back to PRs

#8117: Agents: sanitize tool call ids for OpenAI

by TylonHH open 2026-02-03 16:19 View on GitHub →
docker agents stale size: M
Agents: sanitize tool call ids for OpenAI ## Summary - Sanitize tool call IDs for OpenAI/OpenRouter to keep them within the 40-char limit. - Apply tool-call ID sanitization even when using images-only transcript sanitization. - Update sanitize-session-history tests for openai-responses behavior. ## Why OpenAI/OpenRouter reject tool calls when `tool_calls[].id` exceeds 40 chars. We only sanitized for Google/Mistral before, so OpenAI/OpenRouter could fail with: `Invalid 'messages[...].tool_calls[0].id': string too long`. ## Testing - Not run (config-only fix; relies on existing unit coverage) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR extends transcript/tool-call sanitization so OpenAI-family APIs (including OpenAI-compatible routing via OpenRouter/OpenCode) get tool call IDs rewritten to meet OpenAI’s 40-char limit and character constraints. It updates the transcript policy to enable tool-call ID sanitization for `modelApi` in the OpenAI set, ensures sanitization can run even under `images-only` mode, and adds/updates unit tests to cover OpenAI `tool_calls[].id` and `tool_call_id` rewrites plus the OpenRouter routing case. Main potential issues are around (1) mixed message schema compatibility (OpenAI `tool` vs internal `toolResult` field names) where sanitization may not keep both sides in sync, and (2) an unrelated Docker default `CMD` change that could break existing container usage. <h3>Confidence Score: 3/5</h3> - This PR is reasonably safe to merge, but has a couple of edge-case and deployment-behavior concerns worth addressing first. - Core logic change is small and has targeted tests, but the tool-call id rewrite may fail to keep IDs consistent when transcripts mix OpenAI-style `tool_call_id` and internal `toolCallId` fields, and the Dockerfile CMD change appears unrelated and could break existing deployments. - src/agents/tool-call-id.ts (mixed schema rewrite behavior), Dockerfile (entrypoint behavior change) <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs