fix(openai): move tool images into user messages - #2923
Merged
Conversation
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.
Summary
Keep Chat Completions tool results as strings and move their image attachments into a following user message. Emit that message after the complete contiguous batch of tool results, preserving tool-call associations and image order.
Fixes #2888
Type and Areas
Type: Bug fix
Areas: AI adapters (OpenAI Chat Completions)
Motivation / Impact
A
view_imageresult previously serializedimage_urlparts insiderole: "tool". Strict compatible endpoints reject this shape, which can also break subsequent requests that reuse the history. The updated conversion keeps the tool text and IDs intact while providing the images through supported user content. Tool text that resembles a JSON content-parts array remains a string.Verification
pnpm run fmt:rsandgit diff --check: passed.cargo test -p openbitfun-ai-adapters --lib providers::openai::message_converter::tests: 22 passed, including image ordering across parallel tool results, legacy DTO round trips, error results, and unchanged text-only batches.cargo test -p openbitfun-ai-adapters --lib providers::anthropic::message_converter::tests: 3 passed.cargo build -p openbitfun-desktop: passed.view_imageand a follow-up using the same image history, correctly identifying the red/blue fixture. Recorded requests confirmed string tool content and images only in user messages.deepseek-v4-flash-vision-expChat Completions, Anthropic Messages, and Responses each passed both the image request and its history continuation (HTTP 200, correct image answers).Reviewer Notes
Checklist