fix(computer_use): honor custom vision routing

This commit is contained in:
helix4u 2026-06-03 21:03:31 -06:00 committed by Teknium
parent ffe665277c
commit 591e6fb8f4
6 changed files with 207 additions and 7 deletions

View file

@ -241,6 +241,39 @@ class TestCaptureResponseRoutedToAuxVision:
assert observed_path["path"]
assert not os.path.exists(observed_path["path"])
def test_aux_route_creates_missing_cache_dir(self, tmp_path):
from tools.computer_use import tool as cu_tool
cache_dir = tmp_path / "missing" / "cache_vision"
cap = _make_capture(mode="som")
observed_path = {}
def _fake_get(*_args, **_kw):
return cache_dir
def _fake_run_async(_coro):
return _stub_aux_analysis("description goes here")
def _fake_vat(image_path, _prompt):
observed_path["path"] = image_path
assert os.path.exists(image_path)
return "<coro>"
fake_vat = MagicMock(side_effect=_fake_vat)
with patch.object(cu_tool, "_should_route_through_aux_vision",
return_value=True), \
patch("hermes_constants.get_hermes_dir", _fake_get), \
patch("model_tools._run_async", side_effect=_fake_run_async), \
patch("tools.vision_tools.vision_analyze_tool",
new_callable=lambda: fake_vat):
resp = cu_tool._capture_response(cap)
assert isinstance(resp, str)
assert cache_dir.is_dir()
assert observed_path["path"]
assert not os.path.exists(observed_path["path"])
def test_temp_file_cleaned_up_even_when_aux_call_raises(
self, tmp_cache_dir,
):