Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(bot): don't discard vlm-only config when ovcli identity is missing (#2994)
Zayn Jarvisbd1c6c628f8a
diff --git a/bot/vikingbot/config/loader.py b/bot/vikingbot/config/loader.pyindex f4ae8fdf1..669bc2c44 100644--- a/bot/vikingbot/config/loader.py+++ b/bot/vikingbot/config/loader.py@@ -210,8 +210,20 @@ def _fill_user_api_key_from_ovcli(bot_data: dict) -> None:try:cli_config = load_ovcli_config()except ValueError as e:- print(str(e), file=sys.stderr)- raise+ # A missing or invalid ovcli identity only affects OpenViking memory/file+ # tools. It must NOT abort loading the rest of the bot config (LLM/vlm+ # provider, agents, channels): load_config() would otherwise catch this+ # ValueError, discard the whole config and silently fall back to defaults,+ # so a user who only configured `vlm` ends up on the default+ # `openai/*` model with no credentials ("Missing credentials ... set+ # OPENAI_API_KEY") instead of their configured provider. Degraded+ # OpenViking auth is surfaced separately by validate_openviking_auth().+ print(+ f"Warning: could not load OpenViking user API key from ovcli config: {e}\n"+ "OpenViking memory and file tools may not work until this is fixed.",+ file=sys.stderr,+ )+ returnif cli_config and cli_config.api_key:bot_data["api_key"] = cli_config.api_keydiff --git a/bot/vikingbot/tests/unit/test_config/test_vlm_only_config_survives_ovcli_error.py b/bot/vikingbot/tests/unit/test_config/test_vlm_only_config_survives_ovcli_error.pynew file mode 100644index 000000000..8ed43bf1e--- /dev/null+++ b/bot/vikingbot/tests/unit/test_config/test_vlm_only_config_survives_ovcli_error.py@@ -0,0 +1,71 @@+"""Regression test for vlm-only ov.conf losing its provider on ovcli errors.++Repro: with only a `vlm` section configured (no `bot.agents`) and a `server`+section whose effective auth mode is `api_key`, load_config() used to call+_fill_user_api_key_from_ovcli() -> load_ovcli_config(), which raises ValueError+when no valid ovcli identity exists. load_config()'s broad+`except (json.JSONDecodeError, ValueError)` then swallowed it and fell back to a+default Config(), discarding the vlm-derived model/provider/credentials. The bot+then ran on the default `openai/*` model with no key and failed with+"Missing credentials ... set OPENAI_API_KEY".++An ovcli/user-identity problem must only degrade OpenViking memory/file tools,+never discard the unrelated LLM/vlm provider config.+"""++import json++from vikingbot.config import loader+++def _write_conf(tmp_path, monkeypatch):+ conf = tmp_path / "ov.conf"+ conf.write_text(+ json.dumps(+ {+ "vlm": {+ "provider": "deepseek",+ "api_base": "https://api.deepseek.com",+ "api_key": "sk-deepseek-test-key",+ "model": "deepseek-chat",+ },+ # api_key auth mode is what drives the ovcli user-key lookup.+ "server": {"auth_mode": "api_key"},+ }+ )+ )+ monkeypatch.setattr(loader, "CONFIG_PATH", conf)+ return conf+++def test_vlm_config_preserved_when_ovcli_lookup_fails(tmp_path, monkeypatch):+ _write_conf(tmp_path, monkeypatch)++ def _raise(*_args, **_kwargs):+ raise ValueError("Invalid CLI config: no ovcli identity configured")++ monkeypatch.setattr(loader, "load_ovcli_config", _raise)++ config = loader.load_config()++ # The vlm-derived agent config must survive the ovcli failure.+ assert config.agents.model == "deepseek-chat"+ assert config.agents.provider == "deepseek"+ assert config.agents.api_key == "sk-deepseek-test-key"+ assert config.agents.api_base == "https://api.deepseek.com"+++def test_vlm_config_used_when_ovcli_supplies_user_key(tmp_path, monkeypatch):+ _write_conf(tmp_path, monkeypatch)++ class _Cli:+ api_key = "user-api-key"++ monkeypatch.setattr(loader, "load_ovcli_config", lambda *a, **k: _Cli())++ config = loader.load_config()++ # LLM provider still comes from vlm; ovcli only fills the OpenViking user key.+ assert config.agents.provider == "deepseek"+ assert config.agents.model == "deepseek-chat"+ assert config.ov_server.api_key == "user-api-key"