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): preserve OpenViking credentials with --with-bot (#4847)
黄飞虹45e011ceaf2d
diff --git a/bot/README.md b/bot/README.mdindex 8b13d44e0..9c871a940 100644--- a/bot/README.md+++ b/bot/README.md@@ -64,7 +64,7 @@ ov chat → OpenViking Server → VikingBot Gateway → AgentFollow the [OpenViking quickstart](../docs/en/getting-started/03-quickstart-server.md) to configure the models and storage required by OpenViking. By default, the Bot inherits the root-level `vlm` configuration as its Agent model. Configure `bot.agents` only if the Bot should use a separate model.-In this combined mode, the Bot always uses the OpenViking Server started by the same command and ignores `bot.ov_server` settings that point to another service. OpenViking Server injects an authenticated request-scoped identity into every Chat request sent to the Bot.+In this combined mode, the Bot always uses the OpenViking Server started by the same command. `bot.ov_server.server_url` is ignored, while an explicit `bot.ov_server.api_key` and other Bot OpenViking settings are preserved. In `api_key` mode, that key must be a User/Admin key. OpenViking Server injects an authenticated request-scoped identity into every Chat request sent to the Bot.#### 2. Start both servicesdiff --git a/bot/README_CN.md b/bot/README_CN.mdindex 164961ae1..81bd4e527 100644--- a/bot/README_CN.md+++ b/bot/README_CN.md@@ -61,7 +61,7 @@ ov chat → OpenViking Server → VikingBot Gateway → Agent先按照 [OpenViking 快速开始](../docs/zh/getting-started/03-quickstart-server.md)配置好 OpenViking 所需的模型和存储。Bot 默认继承根级 `vlm` 作为 Agent 模型;如需使用独立模型,再配置 `bot.agents`。-一体启动时,Bot 固定使用当前启动的 OpenViking Server,忽略 `bot.ov_server` 中指向其他服务的配置。OpenViking Server 会为每个 Chat 请求向 Bot 注入已经认证的 request-scoped 身份。+一体启动时,Bot 固定使用当前启动的 OpenViking Server;`bot.ov_server.server_url` 会被忽略,但显式配置的 `bot.ov_server.api_key` 和其他 Bot 侧 OpenViking 设置会保留。`api_key` 模式下,该 key 必须是 User/Admin key。OpenViking Server 会为每个 Chat 请求向 Bot 注入已经认证的 request-scoped 身份。#### 2. 一体启动diff --git a/bot/tests/test_openviking_api_key_type.py b/bot/tests/test_openviking_api_key_type.pyindex c7d9e0ca8..bcfb07549 100644--- a/bot/tests/test_openviking_api_key_type.py+++ b/bot/tests/test_openviking_api_key_type.py@@ -430,7 +430,7 @@ def test_ov_server_without_root_server_section_stays_standalone():assert bot_data["api_key_type"] == "user"-def test_server_managed_load_config_ignores_bot_ov_server(monkeypatch, tmp_path):+def test_server_managed_load_config_preserves_bot_ov_server_credentials(monkeypatch, tmp_path):config_path = tmp_path / "ov.conf"config_path.write_text(json.dumps(@@ -444,6 +444,7 @@ def test_server_managed_load_config_ignores_bot_ov_server(monkeypatch, tmp_path)"bot": {"ov_server": {"server_url": "https://remote.example",+ "api_key_type": "user","api_key": "bot-key",}},@@ -455,9 +456,10 @@ def test_server_managed_load_config_ignores_bot_ov_server(monkeypatch, tmp_path)config = config_loader_module.load_config()assert config.ov_server.server_url == "http://127.0.0.1:1935"- assert config.ov_server.api_key == ""+ assert config.ov_server.api_key == "bot-key"assert config.ov_server.get_config_source() == "inherited"- assert config.ov_server.get_api_key_source() == "none"+ assert config.ov_server.get_api_key_source() == "bot.ov_server.api_key"+ assert config.ov_server.api_key_type == "user"assert config.ov_server.is_server_managed() is True@@ -485,6 +487,9 @@ def test_server_managed_load_config_uses_runtime_server_url(monkeypatch, tmp_patconfig = config_loader_module.load_config()assert config.ov_server.server_url == "http://127.0.0.1:1940"+ assert config.ov_server.api_key == ""+ assert config.ov_server.get_config_source() == "inherited"+ assert config.ov_server.get_api_key_source() == "none"assert config.ov_server.is_server_managed() is Truediff --git a/bot/vikingbot/config/loader.py b/bot/vikingbot/config/loader.pyindex f345e3db7..eb78fadda 100644--- a/bot/vikingbot/config/loader.py+++ b/bot/vikingbot/config/loader.py@@ -159,7 +159,15 @@ def load_config() -> Config:)server_managed = _is_truthy_env(VIKINGBOT_WITH_OPENVIKING_SERVER_ENV)- bot_server_data = {} if server_managed else bot_data.get("ov_server", {})+ configured_bot_server = bot_data.get("ov_server", {})+ # --with-bot owns the server lifecycle and endpoint, but Bot-level+ # OpenViking credentials and settings still belong to the Bot.+ # Ignore only an explicitly configured alternate server URL.+ bot_server_data = (+ _server_managed_bot_server_data(configured_bot_server)+ if server_managed+ else configured_bot_server+ )server_section_present = "server" in full_data and isinstance(full_data.get("server"), dict)@@ -232,6 +240,13 @@ def _merge_vlm_model_config(agents["extra_headers"] = vlm_data["extra_headers"]+def _server_managed_bot_server_data(value: Any) -> dict:+ """Keep Bot OpenViking settings while ignoring an alternate server URL."""+ if not isinstance(value, dict):+ return {}+ return {key: item for key, item in value.items() if key != "server_url"}++def _merge_ov_server_config(bot_data: dict,ov_data: dict,