Skip to content

fix(proxy): 修复 Hermes Bridge 会话识别与 Knowledge 注入 - #960

Open
Vocllum wants to merge 2 commits into
TencentCloud:feat/server_teamfrom
Vocllum:fix/957-hermes-bridge-knowledge-config
Open

fix(proxy): 修复 Hermes Bridge 会话识别与 Knowledge 注入#960
Vocllum wants to merge 2 commits into
TencentCloud:feat/server_teamfrom
Vocllum:fix/957-hermes-bridge-knowledge-config

Conversation

@Vocllum

@Vocllum Vocllum commented Aug 12, 2026

Copy link
Copy Markdown

改动说明

  • Memory Bridge 和 Skill Bridge 收到裸 x-conversation-id 时,兼容查找带 hermes: 前缀的 SessionStore 会话。
  • 在官方 start-proxy.sh 生成的配置中补全注册 KnowledgeToolsInjector 所需的 knowledge 配置段。
  • 分别增加 Bridge Handler 和官方部署配置的回归测试。

根因

Hermes 主请求会以 hermes:hermes-ops-test-001 这类复合键保存 Session,但 Bridge 请求携带的是裸会话 ID hermes-ops-test-001。原有 Bridge 回退逻辑只尝试 codebuddy:claude-code:,没有尝试 hermes:,因此 Session 已初始化时仍会返回 HTTP 401。

官方部署配置虽然在 injection.injectors 中启用了 knowledge,但没有生成 knowledge.enabledknowledge.endpointknowledge.serviceToken。因此 shouldRegisterKnowledgeInjector(config) 始终为 false,knowledge-tools-injector 不会注册。

具体修改

  1. 新增共享的 sessionKeyCandidates(),保留精确键查找和已有前缀顺序,并补充 hermes: 候选键。
  2. Memory Bridge 和 Skill Bridge 的 L1/L2 Session 恢复路径统一使用候选键。
  3. 官方启动脚本生成完整的 knowledge 配置,复用现有 Memory Core 地址和 Gateway Service Token。
  4. 增加裸 Hermes 会话 ID 的 Handler 级测试,以及部署配置回归测试。

数据安全

本次修改不会重写、迁移、删除或重新分组任何记忆记录。Session 候选键只影响 Bridge 请求对 SessionStore 的查询;Knowledge Injector 只读取知识资产并生成工具说明,不会修改 L0/L1/L2 记忆数据。

验证结果

修复前,SessionStore 中已存在 hermes:hermes-ops-test-001 时,两个 Bridge 使用裸 ID 请求均返回 HTTP 401。修复后,两个 Handler 都能恢复已初始化的 Session,向上游传递正确的 user/team/agent/task 身份并返回 HTTP 200。

Test Files  2 passed (2)
Tests       3 passed (3)

git diff --check origin/feat/server_team...HEAD 通过。

仓库级 npx tsc --noEmit 仍会报告基线中已有的错误,涉及 src/config.ts、Claude Code/CodeBuddy Session 初始化器以及可选依赖 @context-proxy/cost-guard;本次修改没有引入新的类型错误。

Fixes #957

@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Thank you for your attention and contribution! We will schedule an internal review of this PR, and we will share any feedback right here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Hermes integration: memory bridge cannot resolve hermes session and Wiki knowledge injector is not registered

2 participants