fix: honour vision=false by stripping image_url blocks before API call#1717
Open
Veyal wants to merge 1 commit into
Open
fix: honour vision=false by stripping image_url blocks before API call#1717Veyal wants to merge 1 commit into
Veyal wants to merge 1 commit into
Conversation
The vision flag on ModelConfig was defined but never consulted when
building the message payload sent to LiteLLM. Any conversation with
image attachments forwarded image_url content to the model even when
vision was disabled, causing OpenRouter (and other providers) to return:
{"error":{"message":"No endpoints found that support image input"}}
- Add strip_images() to helpers/images.py that removes image_url blocks
from a content list and collapses a single leftover text block back to
a plain string.
- In LiteLLMChatWrapper._convert_messages, read vision from
a0_model_conf and call strip_images() when vision is False.
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
When a user sets
vision: falseon their chat model, Agent Zero still forwardsimage_urlcontent blocks to the LLM provider. This causes providers that do not support image input (most text-only models on OpenRouter and others) to return:The
visionfield onModelConfigwas defined but never consulted when building the message payload inLiteLLMChatWrapper._convert_messages. All message content, including images, was passed throughimages.prepare_content()unconditionally.Fix
helpers/images.py— addsstrip_images(content)which removesimage_urlblocks from a content list:""instead of[]to avoid empty-content API errors[{"type":"text","text":"..."}]back to a plain stringmodels.py—_convert_messagesnow readsself.a0_model_conf.visionand callsstrip_images()when vision is disabled.Tests
7 new unit tests added to
tests/test_vision_load_image_refs.pycovering:""""All 7 tests pass.
Reproduction
deepseek/deepseek-r2) on OpenRouterNo endpoints found that support image inputis returned