Compare commits

...

1 Commits

Author SHA1 Message Date
alt-glitch
5eaceb82af fix(setup): skip AUXILIARY_VISION_MODEL write when input is blank
Blank input at the non-OpenAI vision model prompt was unconditionally
written to .env, overwriting any existing custom model.
2026-04-25 09:59:11 +05:30
2 changed files with 19 additions and 1 deletions

View File

@@ -867,7 +867,8 @@ def setup_model_provider(config: dict, *, quick: bool = False):
) )
else: else:
_selected_vision_model = prompt(" Vision model (blank = use main/custom default)").strip() _selected_vision_model = prompt(" Vision model (blank = use main/custom default)").strip()
save_env_value("AUXILIARY_VISION_MODEL", _selected_vision_model) if _selected_vision_model:
save_env_value("AUXILIARY_VISION_MODEL", _selected_vision_model)
print_success( print_success(
f"Vision configured with {_base_url}" f"Vision configured with {_base_url}"
+ (f" ({_selected_vision_model})" if _selected_vision_model else "") + (f" ({_selected_vision_model})" if _selected_vision_model else "")

View File

@@ -527,3 +527,20 @@ def test_offer_launch_chat_manual_fallback_when_unresolvable(monkeypatch, capsys
captured = capsys.readouterr() captured = capsys.readouterr()
assert "Run 'hermes chat' manually" in captured.out assert "Run 'hermes chat' manually" in captured.out
class TestVisionModelBlankGuard:
"""Regression: blank vision model input must not overwrite existing .env value."""
def test_save_env_value_overwrites_with_empty(self, tmp_path, monkeypatch):
"""Proves save_env_value has no internal guard — caller must guard."""
env_path = tmp_path / ".env"
env_path.write_text("AUXILIARY_VISION_MODEL=custom-model\n")
monkeypatch.setattr("hermes_cli.config.get_env_path", lambda: env_path)
from hermes_cli.config import save_env_value
save_env_value("AUXILIARY_VISION_MODEL", "")
# save_env_value DOES overwrite — this is by design.
# The guard must be at the call site in setup.py.
assert "AUXILIARY_VISION_MODEL=\n" in env_path.read_text()