Conversation
When the primary model (vision-capable) dies mid-turn and the fallback chain lands on a text-only model, two bugs occur: 1. Inline image_url parts in api_messages cause HTTP 400 — the text-only model rejects image bytes it cannot process. 2. vision_analyze tool calls still use the native fast path — _should_use_native_vision_fast_path reads stale runtime-main globals still pointing at the vision-capable primary, so every vision_analyze call returns image bytes that the text-only fallback cannot process. Fix: _sync_failover_vision_support (called after every provider failover): - Looks up the failover model's vision capability via _lookup_supports_vision - If text-only and image parts present — describes each image via the auxiliary vision LLM and replaces the part in place with text - Falls back to a plaintext placeholder if aux vision fails - Sets agent._vision_supported = False - Sets module-level _failover_vision_disabled flag in vision_tools _should_use_native_vision_fast_path (vision_tools.py): - Checks _failover_vision_disabled at the top — returns False when set, forcing vision_analyze through the auxiliary vision text path turn_context.build_turn_context: - Clears _failover_vision_disabled on primary restore, re-enabling the native fast path when the vision-capable primary is back Co-authored-by: Hermes Agent <hermes-agent[bot]@users.noreply.github.com>
viz-A-viz
force-pushed
the
fix/failover-vision-description
branch
from
August 11, 2026 01:47
7d4c3e6 to
a6e742d
Compare
19 tasks
13 tasks
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 the primary model (vision-capable) dies mid-turn and the fallback chain lands on a text-only model (e.g. DeepSeek), two bugs occur:
Inline image parts in api_messages cause 400 errors — the text-only model rejects
image_urlparts it cannot process.vision_analyzetool still uses the native fast path —_should_use_native_vision_fast_path()reads stale runtime-main globals (still pointing at the vision-capable primary), so everyvision_analyzecall returns image bytes that the text-only fallback model cannot process.Fix
_sync_failover_vision_support(called after every provider failover):_lookup_supports_visionagent._vision_supported = False_failover_vision_disabledflag invision_tools_should_use_native_vision_fast_path(vision_tools.py):_failover_vision_disabledat the top — returnsFalsewhen set, forcingvision_analyzethrough the auxiliary vision text pathturn_context.build_turn_context:_failover_vision_disabledon primary restore, re-enabling the native fast path when the vision-capable primary is backTests
TestFailoverVisionSupport(5 cases): text-only replacement, aux-vision failure placeholder, vision-capable pass-through, already-unsupported skip, tool-message linkage.TestFailoverVisionDisablesFastPath(2 cases): text-only failover sets the vision_tools flag, fast path returns False when flag is set.