Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(bot): forward actor_peer_id through openviking_connection (#4650)

LI6c04e2ad4248
diff --git a/openviking/server/routers/bot.py b/openviking/server/routers/bot.py
index 69d863c16..1860e37c7 100644
--- a/openviking/server/routers/bot.py
+++ b/openviking/server/routers/bot.py
@@ -85,6 +85,11 @@ def _build_openviking_connection(
}
if api_key:
connection["api_key"] = api_key
+ # Preserve request-scoped actor peer so vikingbot does not fall back to
+ # body user_id / authenticated OpenViking user_id (#4649).
+ actor_peer_id = str(ctx.actor_peer_id or "").strip()
+ if actor_peer_id:
+ connection["actor_peer_id"] = actor_peer_id
return connection
diff --git a/tests/server/test_bot_actor_peer_forward.py b/tests/server/test_bot_actor_peer_forward.py
new file mode 100644
index 000000000..493e1bfcf
--- /dev/null
+++ b/tests/server/test_bot_actor_peer_forward.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
+# SPDX-License-Identifier: AGPL-3.0
+
+from openviking.server.identity import RequestContext, Role
+from openviking.server.routers.bot import _build_openviking_connection
+from openviking_cli.session.user_id import UserIdentifier
+
+
+def test_build_openviking_connection_forwards_actor_peer_id():
+ ctx = RequestContext(
+ user=UserIdentifier("acct", "alice"),
+ role=Role.USER,
+ actor_peer_id="peer-a",
+ )
+ connection = _build_openviking_connection(
+ api_key="user-key",
+ ctx=ctx,
+ effective_auth_mode="api_key",
+ server_url="http://127.0.0.1:1933",
+ )
+ # Assert the OpenViking-side forward only; vikingbot owns connection > body fallback.
+ assert connection["actor_peer_id"] == "peer-a"
+
+
+def test_build_openviking_connection_omits_blank_actor_peer_id():
+ ctx = RequestContext(
+ user=UserIdentifier("acct", "alice"),
+ role=Role.USER,
+ actor_peer_id=" ",
+ )
+ connection = _build_openviking_connection(
+ api_key="user-key",
+ ctx=ctx,
+ effective_auth_mode="api_key",
+ server_url="http://127.0.0.1:1933",
+ )
+ assert "actor_peer_id" not in connection