feat: Wire Gemma 4 vision into browser_tool for screenshot analysis
All checks were successful
Lint / lint (pull_request) Successful in 8s

Default browser_vision screenshots to google/gemma-4-27b-it (Gemma 4
native multimodal) for reduced latency and unified text+vision model.

Resolution order for _get_vision_model():
1. BROWSER_VISION_MODEL env var (new, browser-specific override)
2. auxiliary.browser_vision.model in config.yaml (new config key)
3. AUXILIARY_VISION_MODEL env var (existing global vision override)
4. Default: google/gemma-4-27b-it

Backward compatibility: existing AUXILIARY_VISION_MODEL users are
unaffected — their override still flows through to browser_vision.

Also documents the new auxiliary.browser_vision config section in
cli-config.yaml.example and adds 14 unit tests covering the full
priority chain.

Fixes #816

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Whitestone
2026-04-21 17:12:58 -04:00
parent 12b5d9a7fd
commit 95bb842a21
3 changed files with 34 additions and 2 deletions

View File

@@ -1,4 +1,12 @@
"""Tests for browser_tool._get_vision_model() — Gemma 4 default (Issue #816)."""
"""Tests for browser_tool._get_vision_model() — Gemma 4 default (Issue #816).
Covers acceptance criteria from issue #816:
- Browser screenshots use Gemma 4 by default.
- BROWSER_VISION_MODEL env var overrides the model for browser vision only.
- AUXILIARY_VISION_MODEL env var still works as a global override.
- auxiliary.browser_vision.model in config.yaml overrides the default.
- Priority: BROWSER_VISION_MODEL > config.yaml > AUXILIARY_VISION_MODEL > default.
"""
import importlib
import sys
@@ -96,3 +104,26 @@ class TestGetVisionModelConfig:
with patch("hermes_cli.config.load_config", return_value=cfg):
import tools.browser_tool as bt
assert bt._get_vision_model() == "openai/gpt-4o"
def test_config_beats_auxiliary_vision_model(self, monkeypatch):
"""Config should override AUXILIARY_VISION_MODEL when BROWSER_VISION_MODEL unset."""
monkeypatch.delenv("BROWSER_VISION_MODEL", raising=False)
monkeypatch.setenv("AUXILIARY_VISION_MODEL", "global-override")
cfg = {"auxiliary": {"browser_vision": {"model": "config-model"}}}
with patch("hermes_cli.config.load_config", return_value=cfg):
import tools.browser_tool as bt
assert bt._get_vision_model() == "config-model"
class TestBackwardCompatibility:
"""AUXILIARY_VISION_MODEL must still work for users who already have it configured."""
def test_existing_auxiliary_vision_model_not_broken(self, monkeypatch):
"""Users who set AUXILIARY_VISION_MODEL must not be broken by this change."""
monkeypatch.delenv("BROWSER_VISION_MODEL", raising=False)
monkeypatch.setenv("AUXILIARY_VISION_MODEL", "openai/gpt-4o")
import tools.browser_tool as bt
with patch("hermes_cli.config.load_config", return_value={}):
model = bt._get_vision_model()
assert model == "openai/gpt-4o"
assert model != "google/gemma-4-27b-it"