Repository navigation
fix(providers): keep tool batches ahead of media messages - #64
Merged
Merged
Conversation
Defer synthetic user media until all contiguous tool-result messages have been emitted. OpenAI rejects media inserted between replies to parallel tool calls. Preserve accompanying text and the order of media payloads. Cover both Chat Completions serializers with separate and grouped tool results, two media results, and following conversation messages. > Xum acted on Mike's behalf.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ibetitsmike
added a commit
to coder/coder
that referenced
this pull request
Oct 9, 2026
coder/fantasy#64 and #65 merged the OpenAI media-batch fix and the Anthropic empty web search fix into coder_2_33, so the pin no longer points at unmerged branches. The new commit's source tree is identical to the previous pin's.
This was referenced Oct 9, 2026
fix: fold web searches, answer reasoning, and OpenAI narration into working blocks
coder/coder#30529
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The OpenAI and OpenAI-compatible Chat Completions serializers send a tool result's media (for example a screenshot from an MCP tool) as a synthetic user message right after that tool's reply. When the assistant made parallel tool calls, that user message lands between the tool replies of one batch, and OpenAI rejects the request.
Fix
Hold the synthetic media messages until the run of tool replies ends, then emit them in their original order. Each tool reply keeps its text. The change is the same in
providers/openaiandproviders/openaicompat.Validation
TestToolMediaFollowsToolResultBatchcovers both serializers with separate and grouped tool results, two media results, and following conversation messages. With thecoder_2_33serializers overlaid viago test -overlay, 12 subtests fail; with the fix they pass.go build ./...andgo test ./providers/openai/... ./providers/openaicompat/...pass.9a35984) since fix: keep text and image together in MCP tool results coder#29332 on September 17. fix: fold web searches, answer reasoning, and OpenAI narration into working blocks coder#30529 moves that pin tocoder_2_33once this and a follow-up Anthropic fix merge.coder_2_33(a511353) and on this branch, so they are not introduced here.The second commit on the branch only merges
coder_2_33in, so a squash merge leaves the single fix.