Skip to content

fix(vision): accept base64 data: URLs in vision_analyze - #30197

Closed
elozadaf wants to merge 1 commit into
NousResearch:mainfrom
elozadaf:fix/vision-data-url-support
Closed

fix(vision): accept base64 data: URLs in vision_analyze#30197
elozadaf wants to merge 1 commit into
NousResearch:mainfrom
elozadaf:fix/vision-data-url-support

Conversation

@elozadaf

Copy link
Copy Markdown

Problem

vision_analyze's image-source resolver accepts only 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 is rejected with:

Invalid image source. Provide an HTTP/HTTPS URL or a valid local file path.

Fix

New _data_url_to_temp_file() in tools/vision_tools.py decodes a data: URL to a temp image file. Both source-resolution paths — _vision_analyze_native (fast path) and vision_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.

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).
@alt-glitch alt-glitch added type/bug Something isn't working tool/vision Vision analysis and image generation P2 Medium — degraded but workaround exists labels May 22, 2026
@teknium1

teknium1 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Closing — base64 data: URL support for vision_analyze landed on main via PR #57890's unified image-source resolver (tools/image_source.py), which handles data:/http(s)/file/local/container sources through one chokepoint with validated base64 decode and magic-byte MIME sniffing. Your PR correctly identified the gap and was submitted well before the resolver work; it's credited in #57890's fix list. Thanks for the report and the fix!

@teknium1 teknium1 closed this Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants