Skip to content

fix(providers): keep tool batches ahead of media messages - #64

Merged
ibetitsmike merged 2 commits into
coder_2_33from
mike/mcp-tool-media-batch-order
Oct 9, 2026
Merged

ibetitsmike merged 2 commits into
coder_2_33from
mike/mcp-tool-media-batch-order

Conversation

@ibetitsmike

Copy link
Copy Markdown

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/openai and providers/openaicompat.

Validation

The second commit on the branch only merges coder_2_33 in, so a squash merge leaves the single fix.

Xum acted on Mike's (@ibetitsmike) behalf to create this PR.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T09:14:36.113382Z 9a35984 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike
ibetitsmike merged commit fec0a02 into coder_2_33 Oct 9, 2026
6 of 7 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant