The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(local-runtime): vision_analyze's native path also transcodes WebP for the managed server
emozilla663413e3bbd9
diff --git a/tests/hermes_cli/test_managed_vision_capability.py b/tests/hermes_cli/test_managed_vision_capability.pyindex 1ad35b1a4b2..661976b88d1 100644--- a/tests/hermes_cli/test_managed_vision_capability.py+++ b/tests/hermes_cli/test_managed_vision_capability.py@@ -154,3 +154,32 @@ def test_webp_passes_through_for_cloud_providers(hermes_home, monkeypatch, tmp_pdata_url = ir._file_to_data_url(webp_path)assert data_url is not Noneassert data_url.startswith("data:image/webp;base64,")+++def test_vision_analyze_normalization_narrows_for_managed(hermes_home, monkeypatch, tmp_path):+ """vision_analyze's native fast path embeds the image into conversation+ history via _normalize_to_supported_image — for the managed server a+ WebP must convert to PNG THERE too, or the tool path re-introduces the+ silent-drop confabulation the attachment path just fixed."""+ pytest.importorskip("PIL")+ from PIL import Image++ import tools.vision_tools as vt++ webp_path = tmp_path / "img.webp"+ Image.new("RGB", (32, 32), (255, 0, 0)).save(webp_path, format="WEBP")++ monkeypatch.setattr("agent.auxiliary_client._runtime_main_value",+ lambda k: {"provider": "llamacpp",+ "base_url": ""}.get(k, ""))+ out_path, mime, err = vt._normalize_to_supported_image(webp_path, "image/webp")+ assert err is None+ assert mime == "image/png", "managed server: webp must normalize to png"++ # Cloud providers keep webp untouched.+ monkeypatch.setattr("agent.auxiliary_client._runtime_main_value",+ lambda k: {"provider": "anthropic",+ "base_url": ""}.get(k, ""))+ out_path, mime, err = vt._normalize_to_supported_image(webp_path, "image/webp")+ assert err is None+ assert mime == "image/webp"diff --git a/tools/vision_tools.py b/tools/vision_tools.pyindex e008983f7f2..b89037f3502 100644--- a/tools/vision_tools.py+++ b/tools/vision_tools.py@@ -274,6 +274,30 @@ _ANTHROPIC_SUPPORTED_MEDIA_TYPES = frozenset()+def _supported_media_types() -> frozenset:+ """Formats the ACTIVE main model's server can decode.++ Cloud providers take everything in _ANTHROPIC_SUPPORTED_MEDIA_TYPES.+ The managed llama-server decodes with stb_image — no WebP — and an+ undecodable image part fails SILENTLY (no error; the model never sees+ an image and confabulates). Narrow the set so normalization converts+ those formats to PNG before they enter the request or history."""+ try:+ from agent.auxiliary_client import _runtime_main_value+ from hermes_cli.local_runtime.capabilities import (+ ACCEPTED_IMAGE_MIMES,+ is_managed_provider,+ )++ if is_managed_provider(+ str(_runtime_main_value("provider") or ""),+ str(_runtime_main_value("base_url") or "")):+ return ACCEPTED_IMAGE_MIMES+ except Exception: # noqa: BLE001 — best-effort narrowing only+ pass+ return _ANTHROPIC_SUPPORTED_MEDIA_TYPES++def _rasterize_svg_to_png(svg_path: Path, out_path: Path) -> bool:"""Best-effort SVG → PNG rasterization. Returns True on success.@@ -337,7 +361,7 @@ def _normalize_to_supported_image(the image is base64-embedded into conversation history, so an unsupportedmedia_type can never reach the provider and wedge the session."""- if detected_mime in _ANTHROPIC_SUPPORTED_MEDIA_TYPES:+ if detected_mime in _supported_media_types():return image_path, detected_mime, Noneout_dir = get_hermes_dir("cache/vision", "temp_vision_images")