Skip to content

feat(llm): 透传 conversationId 至 Anthropic metadata.user_id - #22

Open
DeliciousBuding wants to merge 1 commit into
CometixSpace:mainfrom
DeliciousBuding:feat/anthropic-conversation-metadata
Open

feat(llm): 透传 conversationId 至 Anthropic metadata.user_id#22
DeliciousBuding wants to merge 1 commit into
CometixSpace:mainfrom
DeliciousBuding:feat/anthropic-conversation-metadata

Conversation

@DeliciousBuding

Copy link
Copy Markdown

实现 #21

变更

  • anthropic.tsconversationId 存在时注入 params.metadata = { user_id },缺省时不注入(请求体保持不变)
  • 新增 anthropicAffinity.test.ts:3 用例——有 conversationId 时注入 / 无时缺省 / 会话间隔离

背景

验证

  • vitest run src/server/tests/anthropicAffinity.test.ts 3/3 通过
  • tsc --noEmit 零错误;eslint 零告警
  • 全量测试套零回归(基线行为不变,可选字段缺省不注入)

为下游网关的会话级粘性路由 (session affinity) 提供稳定会话键:
conversationId 存在时注入 metadata.user_id, 缺省时不注入。

- 与 OpenAI 路径已有的 prompt_cache_key 透传语义对称
- 官方客户端 Claude Code 同样在该字段携带 session 维度
- 新增 3 用例单测 (注入/缺省/会话隔离)

Co-authored-by: Claude Code <claude@vectorcontrol.tech>
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.

1 participant