Files
agent-zero/tests/test_vision_tool_ui.py
linkliti 4369c31aaa feat(vision): render vision tool calls through a dedicated badge
The vision tool logs its messages as a dedicated vision_load type with an icon verb headline naming the first image and appending + N more for additional images, and passes its arguments through to the log. A core message-handler extension renders the type as the EYE badge and the process-step registry claims it, so the legacy tool-name fallback branch for vision rows is removed. Regression tests cover the log entry and the headline counts.

Validation: pytest tests/test_vision_tool_ui.py
2026-10-21 23:37:32 +03:00

36 lines
1.2 KiB
Python

from types import SimpleNamespace
from tools.vision_load import VisionLoad
class _FakeLog:
def log(self, **kwargs) -> dict:
return kwargs
class _FakeAgent:
def __init__(self) -> None:
self.context = SimpleNamespace(log=_FakeLog())
def _make_tool(args: dict) -> VisionLoad:
return VisionLoad(
agent=_FakeAgent(), name="vision_load", method="execute", args=args, message="", loop_data=None
)
def test_log_object_uses_dedicated_type_and_passthrough():
tool = _make_tool({"paths": ["/tmp/report.png"], "query": "charts"})
entry = tool.get_log_object()
assert entry["type"] == "vision_load"
assert entry["heading"] == "icon://imagesmode Loading images: report.png"
assert entry["kvps"] == {"paths": ["/tmp/report.png"], "query": "charts"}
def test_get_headings_count_extra_images():
assert _make_tool({}).get_heading() == "icon://imagesmode Loading images"
assert _make_tool({"paths": ["/tmp/report.png"]}).get_heading() == "icon://imagesmode Loading images: report.png"
assert _make_tool({"paths": ["/tmp/a.png", "/tmp/b.png", "/tmp/c.png"]}).get_heading() == "icon://imagesmode Loading images: a.png + 2 more"