Agent Zero AI framework
Reject empty Vision Model responses
Alessandro1d922aaab27f
diff --git a/tests/test_vision_load_image_refs.py b/tests/test_vision_load_image_refs.pyindex aba0ceb72..43540b11b 100644--- a/tests/test_vision_load_image_refs.py+++ b/tests/test_vision_load_image_refs.py@@ -242,6 +242,47 @@ async def test_vision_model_sends_multiple_images_once_and_keeps_history_text_onassert tool_results[0][1]["_responses_output_item"]["output"] == response.message+async def test_vision_model_empty_response_is_reported_as_error(monkeypatch):+ _install_tool_stub(monkeypatch)+ import tools.vision_load as vision_load_module++ class FakeVisionModel:+ async def unified_call(self, **kwargs):+ return "", ""++ monkeypatch.setattr(+ vision_load_module,+ "build_vision_model",+ lambda _agent: FakeVisionModel(),+ )+ monkeypatch.setattr(+ vision_load_module,+ "get_vision_model_config",+ lambda _agent: {"provider": "test", "name": "vision", "max_embeds": 10},+ )++ agent = SimpleNamespace(+ context=SimpleNamespace(id="", get_data=lambda _key: ""),+ last_user_message=SimpleNamespace(output_text=lambda: "Inspect the image."),+ read_prompt=lambda _name, request: request,+ )+ tool = vision_load_module.VisionLoad(+ agent=agent,+ name="vision_load",+ method=None,+ args={"paths": ["data:image/png;base64,AA=="]},+ message="",+ loop_data=None,+ )++ response = await tool.execute(paths=["data:image/png;base64,AA=="])++ assert response.message == (+ "Image analysis error: Vision Model returned an empty response."+ )++@pytest.mark.anyioasync def test_parallel_worker_consumes_parent_ephemeral_image(monkeypatch, tmp_path):_install_tool_stub(monkeypatch)diff --git a/tools/vision_load.py b/tools/vision_load.pyindex 51f4f33b2..791a4dfce 100644--- a/tools/vision_load.py+++ b/tools/vision_load.py@@ -116,6 +116,8 @@ class VisionLoad(Tool):response, _ = await build_vision_model(self.agent).unified_call(messages=[HumanMessage(content=content)],)+ if not str(response or "").strip():+ raise RuntimeError("Vision Model returned an empty response.")return str(response)def _store_ephemeral_image(self, image: ephemeral_images.EphemeralImage) -> str:diff --git a/tools/vision_load.py.dox.md b/tools/vision_load.py.dox.mdindex c0ea776e5..ef09102e0 100644--- a/tools/vision_load.py.dox.md+++ b/tools/vision_load.py.dox.md@@ -27,6 +27,7 @@- Direct parallel workers inherit the parent's model override generically. This tool uses their recorded parent context only to resolve ephemeral refs and durable chat media.- `max_embeds` comes from the model that actually receives the images.- Vision Model calls use the selected model's Advanced `kwargs`; this tool does not impose a separate timeout or output-token limit.+- An empty Vision Model response is reported as an image-analysis error instead of a successful empty capsule.- Update this file whenever tool arguments, output shape, `break_loop` behavior, intervention handling, prompt instructions, or side effects change.- `VisionLoad` is a `Tool`.- `VisionLoad` defines `execute(...)`.