[codex] add multimodal support across providers and unify media retries#37
Merged
[codex] add multimodal support across providers and unify media retries#37
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
This PR adds first-class multimodal structured extraction support for all major providers in
rstructor(OpenAI, Anthropic, Grok), and fixes Gemini media-path retry parity.Problem
Before this change,
materialize_with_mediaonly worked in the Gemini backend. For OpenAI, Anthropic, and Grok, media inputs were accepted by the public API but effectively ignored because provider request serialization only emitted text content.Additionally, Gemini's media path bypassed the existing retry-with-conversation-history flow used by text materialization, which reduced recovery reliability after validation failures.
User Impact
materialize_with_media(...)consistently across OpenAI, Anthropic, Grok, and Gemini.Root Cause
content: Stringonly.ChatMessage::user(prompt).Fix
generate_with_retry_with_initial_messages(...)generate_with_retry_with_history(...)now delegates to it.contentparts withtype: textandtype: image_url.contentblocks withtype: textandtype: image+source(base64orurl).materialize_with_media(...)and invoke retry with initial media-bearing messages.materialize_with_media(...)to use retry/history path (parity fix).media_to_url(...)helper for normalized data-URL/URI handling in compatible providers.gpt-5.2-chat-latest,gpt-5.2-codexgemini-2.5-flash-image,gemini-2.0-flash-lite-001Validation
cargo fmt --allcargo clippy --all-targets --all-features -- -D warningscargo test --all-features --no-runcargo test --all-features --test openai_multimodal_tests -- --nocapturecargo test --all-features --test anthropic_multimodal_tests -- --nocapturecargo test --all-features --test grok_multimodal_tests -- --nocapturecargo test --all-features --test gemini_multimodal_tests -- --nocapturecargo test --all-features --test model_string_testcargo test --all-features test_generate_with_retry_with_initial_messages -- --nocaptureAll checks passed locally.