[集成痛点] OpenClaw v2026.5.3-1 与 OpenViking 多租户认证死锁:ROOT Key 强制要求 tenant headers 但 OpenClaw Zod 验证器无法传递 accountId/userId
Problem Statement
问题概述
当 OpenClaw v2026.5.3-1 与 OpenViking Docker (v0.3.14) 集成时,存在一个结构性死锁:
- OpenViking 服务端:配置了
root_api_key后,所有使用 Root Key 的租户级 API 调用必须携带X-OpenViking-Account和X-OpenViking-Userheaders,否则返回INVALID_ARGUMENT: ROOT requests to tenant-scoped APIs must include... - OpenClaw 插件端:OpenClaw Gateway 的 Zod 验证器拒绝
plugins.entries.openviking.config中包含accountId/userId/mode等插件特定字段,将其视为additional properties导致 Gateway 无法启动(相关:openclaw/openclaw#49495)
结果:无法在不破坏 Gateway 启动的前提下,向 OpenViking 传递租户身份信息。
环境信息
| 组件 | 版本 |
|---|---|
| OpenClaw | 2026.5.3-1 (2eae30e) |
| OpenViking | Docker latest (v0.3.14) |
| 操作系统 | Ubuntu 24.04 LTS |
| Node.js | v22.22.2 |
| 部署方式 | OpenViking Docker 本地,端口 1933 |
复现步骤
-
配置 OpenViking Docker
ov.conf:{ "host": "0.0.0.0", "port": 1933, "root_api_key": "【请填写你的 root_api_key】" } -
在
openclaw.json中尝试添加租户字段:{ "openviking": { "enabled": true, "config": { "baseUrl": "http://127.0.0.1:1933", "apiKey": "【请填写 root_api_key】", "mode": "remote", "accountId": "【请填写账户ID,如 main】", "userId": "【请填写用户ID,如 user】" } } } -
结果:Gateway 启动失败,
openclaw config validate报错:must NOT have additional properties: mode, accountId, userId -
移除
mode/accountId/userId后 Gateway 能启动,但 OpenViking 日志报错:INVALID_ARGUMENT: ROOT requests to tenant-scoped APIs must include X-OpenViking-Account and X-OpenViking-User headers
Proposed Solution
已验证的解决方案(User Key 模式)
经过与 OpenClaw 社区交叉验证,推荐以下集成方式:
第一步:生成 User Key(使用 Root Key 调用 Admin API)
# 1. 创建账户(如已存在会返回 409,可忽略)
curl -X POST http://127.0.0.1:1933/api/v1/admin/accounts \
-H "X-API-Key: 【请填写你的 root_api_key】" \
-H "Content-Type: application/json" \
-d '{"account_id": "【请填写你的账户ID】", "admin_user_id": "【请填写你的用户ID】"}'
# 2. 为该账户/用户生成 User Key
curl -X POST http://127.0.0.1:1933/api/v1/admin/accounts/【请填写账户ID】/users/【请填写用户ID】/key \
-H "X-API-Key: 【请填写你的 root_api_key】" \
-H "Content-Type: application/json"
返回示例:
{
"status": "ok",
"result": {
"user_key": "【请填写返回的 user_key,如 ZXZ...】"
}
}
第二步:OpenClaw 使用最小配置(仅 Zod 验证器认可的字段)
{
"openviking": {
"enabled": true,
"config": {
"baseUrl": "http://127.0.0.1:1933",
"apiKey": "【请填写上一步生成的 user_key】"
},
"hooks": {
"allowConversationAccess": true
}
}
}
第三步:验证结果
openclaw config validate # 应返回 Config valid
# 重启 Gateway 后检查日志:
# 预期看到:openviking: registered context-engine
# 不应再出现:INVALID_ARGUMENT / ROOT requests 错误
核心发现
使用 User Key 替代 Root Key 后:
- OpenViking 服务端自动从 User Key 解析
account_id和user_id - 无需
X-OpenViking-Account/X-OpenViking-Userheaders - 无需在 OpenClaw 配置中写入
accountId/userId(避免 Zod 验证失败) - Gateway 正常启动,OpenViking context-engine 正常注册
对 OpenViking 文档的建议
希望官方文档能明确补充以下说明:
- OpenClaw 集成专用章节:说明 User Key 是 OpenClaw 插件的推荐认证方式,而非 Root Key
- Admin API 快速参考:在「OpenClaw 集成」文档中直接给出生成 User Key 的
curl示例 - 错误码说明:
INVALID_ARGUMENT: ROOT requests...错误应提示用户「请使用 User Key 而非 Root Key 进行日常数据访问」 - 单用户/本地开发模式:如果可能,提供一种无需多租户 headers 的简化配置(如关闭
root_api_key的 dev mode)
相关链接
- OpenClaw Issue #49495(Zod 验证器不委托插件 schema):https://github.com/openclaw/openclaw/issues/49495
- OpenViking Issue #1216(accountId/userId 转发):https://github.com/volcengine/OpenViking/issues/1216
- OpenClaw 官方 OpenViking 集成文档:https://docs.openviking.ai/en/agent-integrations/03-openclaw
Alternatives Considered
No response
Feature Area
Documentation
Use Case
我在阿里云服务器(弗吉尼亚 8GB)上部署了 OpenClaw v2026.5.3-1 作为个人 AI 助手的 Gateway,使用 OpenViking Docker 作为向量记忆后端。
当前场景:
- 单用户本地部署,但需要 OpenViking 的多租户隔离能力
- OpenClaw 的 Zod 验证器阻止传递 accountId/userId 给 OpenViking 插件
- 导致 Gateway 无法启动,或 OpenViking 拒绝 ROOT 请求
使用 User Key 方案后,OpenViking context-engine 成功注册,向量记忆功能恢复正常。
希望官方文档能明确这种「OpenClaw + OpenViking 本地集成」的标准配置方式,避免其他用户踩同样的坑。
Example API (Optional)
Additional Context
附件
- OpenClaw 版本:
2026.5.3-1 (2eae30e) - OpenViking Docker 镜像:
ghcr.io/volcengine/openviking:latest - 测试服务器:阿里云 弗吉尼亚 8GB / Ubuntu 24.04
Contribution
- [x] I am willing to contribute to implementing this feature
我们排除下,好像是最近引入的
感谢回复,期待openviking的好消息!
感谢提交这个 issue,也感谢把 OpenClaw 社区侧的交叉验证结果写清楚。
我排查了一下,这里需要分成两个问题来看:
-
Root Key 调租户级 API 需要 tenant headers 是 OpenViking 的预期行为
在
api_key模式下,root_api_key解析为 ROOT 身份。ROOT 访问普通租户数据 API(例如 session/resource/search 等)时,服务端必须知道目标 account/user,因此会要求X-OpenViking-Account和X-OpenViking-User。这个限制是为了避免 ROOT 请求隐式落到default/default,不是 OpenClaw 专用问题。因此 OpenClaw 插件的日常 memory/context-engine 访问不建议直接使用 Root Key,推荐使用 User Key。User Key 会在服务端解析出
account_id/user_id,所以 OpenClaw 配置里只需要baseUrl和apiKey,不需要额外写accountId/userId。 -
你当前提到的 OpenViking
v0.3.14确实有 OpenClaw 插件 schema/安装流程兼容问题v0.3.14对应的 OpenClaw 插件 setup 会写入mode: "remote",但该版本的插件 manifest schema 没有把mode声明为允许字段,所以可能触发 OpenClaw 侧的additional properties校验错误。这个问题已经在后续版本修复。请直接升级到 OpenViking
v0.3.16,并重新安装/升级 OpenClaw 插件。v0.3.16对应的 OpenClaw 插件版本是@openclaw/[email protected],其中包含:- manifest schema 允许
mode - setup/status 会探测 Root Key 场景,并提示 tenant identity 缺失
- 插件保留 User Key 默认路径,不会在未配置
accountId/userId时合成 tenant headers
- manifest schema 允许
推荐配置路径如下:
# 1. 升级 OpenViking 到 v0.3.16
# 如果使用 Docker,请明确拉取/运行 v0.3.16,而不是依赖旧的 latest 缓存。
# 2. 用 Root Key 只做一次 Admin API 操作,创建 account/admin 并取得 user_key
curl -X POST http://127.0.0.1:1933/api/v1/admin/accounts \
-H "X-API-Key: <root_api_key>" \
-H "Content-Type: application/json" \
-d '{"account_id":"main","admin_user_id":"user"}'
# 如账号/用户已存在,也可以为该用户重新生成 User Key
curl -X POST http://127.0.0.1:1933/api/v1/admin/accounts/main/users/user/key \
-H "X-API-Key: <root_api_key>" \
-H "Content-Type: application/json"
# 3. OpenClaw 插件使用返回的 user_key,而不是 root_api_key
openclaw plugins install @openclaw/openviking
openclaw openviking setup --base-url http://127.0.0.1:1933 --api-key <user_key> --json
openclaw gateway restart
配置里建议保持最小形式:
{
"baseUrl": "http://127.0.0.1:1933",
"apiKey": "<user_key>"
}
如果升级到 OpenViking v0.3.16 / @openclaw/[email protected] 后仍然看到 must NOT have additional properties,请再贴一下下面两个命令的输出(注意隐藏 key):
openclaw plugins list
openclaw openviking status --json
这样可以确认 OpenClaw Gateway 实际加载的是不是新插件 manifest,而不是旧的 memory-openviking 或缓存下来的旧版本。