fix(vision): advertise vision_analyze/browser_vision when the main model sees natively
check_vision_requirements only asked the auxiliary resolver, so a vision-capable main model on a provider the resolver cannot serve (minimax-oauth, local vLLM, anything uncatalogued) lost vision_analyze and browser_vision from the tool list even though both handlers already route to the native fast path and work when called. The image gate now accepts the native fast path OR an aux client; the aux-only probe becomes check_video_requirements and stays on video_analyze, whose handler has no native path. Fixes #47149.
This commit is contained in:
@@ -257,3 +257,26 @@ model:
|
||||
import tools.browser_tool
|
||||
with patch.object(bt_install, "check_browser_requirements", return_value=True):
|
||||
assert tools.browser_tool_install.check_browser_vision_requirements() is True
|
||||
|
||||
def test_native_vision_main_advertises_image_tools_but_not_video(self, isolated_home, monkeypatch):
|
||||
"""A vision-capable main model on a provider the aux resolver cannot serve (OAuth, local vLLM)
|
||||
still gets vision_analyze and browser_vision — both handlers attach pixels natively — while
|
||||
video_analyze, whose handler has no native path, stays hidden (#47149)."""
|
||||
from unittest.mock import patch
|
||||
|
||||
_write_config(isolated_home, """
|
||||
model:
|
||||
provider: minimax-oauth
|
||||
default: MiniMax-M3
|
||||
supports_vision: true
|
||||
""")
|
||||
_fresh_modules()
|
||||
|
||||
import tools.browser_tool_install as bt_install
|
||||
from tools import vision_tools
|
||||
|
||||
with patch.object(vision_tools, "_should_use_native_vision_fast_path", return_value=True), \
|
||||
patch.object(bt_install, "check_browser_requirements", return_value=True):
|
||||
assert vision_tools.check_video_requirements() is False # no aux client resolves
|
||||
assert vision_tools.check_vision_requirements() is True
|
||||
assert bt_install.check_browser_vision_requirements() is True
|
||||
|
||||
+11
-2
@@ -797,7 +797,7 @@ async def vision_analyze_tool(
|
||||
return await _run_analysis("image", image_url, user_prompt, model, stage)
|
||||
|
||||
|
||||
def check_vision_requirements() -> bool:
|
||||
def check_video_requirements() -> bool:
|
||||
"""True when ``call_llm(task="vision")`` could resolve a client.
|
||||
|
||||
Mirrors its fallback chain: explicit ``auxiliary.vision.provider``, then auto (main
|
||||
@@ -815,6 +815,15 @@ def check_vision_requirements() -> bool:
|
||||
)
|
||||
|
||||
|
||||
def check_vision_requirements() -> bool:
|
||||
"""Image gate (``vision_analyze``, ``browser_vision``): an aux vision client OR the native fast
|
||||
path. Both handlers attach pixels straight to a vision-capable main model, so a main model on a
|
||||
provider the aux resolver does not know (OAuth, local vLLM) must not hide a working tool (#47149).
|
||||
``video_analyze`` keeps the aux-only gate — its handler has no native path.
|
||||
"""
|
||||
return _should_use_native_vision_fast_path() or check_video_requirements()
|
||||
|
||||
|
||||
from tools.registry import registry, tool_error
|
||||
|
||||
VISION_ANALYZE_SCHEMA = {
|
||||
@@ -1044,7 +1053,7 @@ registry.register(
|
||||
toolset="video",
|
||||
schema=VIDEO_ANALYZE_SCHEMA,
|
||||
handler=_handle_video_analyze,
|
||||
check_fn=check_vision_requirements,
|
||||
check_fn=check_video_requirements,
|
||||
is_async=True,
|
||||
emoji="🎬")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user