fix(vision): accept base64 data: URLs in vision_analyze - #30197
Closed
elozadaf wants to merge 1 commit into
Closed
Conversation
vision_analyze's image-source resolver only accepted http(s) URLs and local file paths. Agents routinely pass an inline base64 data URL — e.g. an image just produced by image_generate and QA'd in the same turn — which was rejected with "Invalid image source. Provide an HTTP/HTTPS URL or a valid local file path." _data_url_to_temp_file() decodes a data: URL to a temp file; both the native fast-path (_vision_analyze_native) and the OpenRouter path (vision_analyze_tool) now handle it. The temp dir is created if missing. Adds tests/tools/test_vision_data_url.py (4 cases).
Contributor
|
Closing — base64 |
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
vision_analyze's image-source resolver accepts onlyhttp(s)://URLs and local file paths. Agents routinely pass an inline base64data:URL — e.g. an image just produced byimage_generateand QA'd in the same turn — which is rejected with:Fix
New
_data_url_to_temp_file()intools/vision_tools.pydecodes adata:URL to a temp image file. Both source-resolution paths —_vision_analyze_native(fast path) andvision_analyze_tool(OpenRouter path) — now handle it before falling through to the rejection. The temp directory is created if missing.Tests
Adds
tests/tools/test_vision_data_url.py— 4 cases (PNG data URL → temp file, JPEG extension normalization, non-data-URL → None, malformed data URL → None). All green.