Skip to content

[PR] fix(#4109): negotiated recall — one lane key for raw and routed - #4116

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-21_recall-routed-key
Oct 21, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-21_recall-routed-key

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

(ai: zhipuai-lb/glm-5.3)

Fixes #4109

什么坏了

桌面版 dsh 的路由通道(settings overlay 把模型请求改写成 http://127.0.0.1:PORT/bili/https://api.anthropic.com/...)上,协商式会话召回(#4082/#4094,救无归属重试)从不触发:学习侧和认领侧用了两个不同的 lane key,永远对不上。

根因

拦截器对同一条请求给两侧传的 URL 形态不同:

  • 认领侧:src/agent/native-intercept.ts 调 state.takeoverGate(routedTarget, …),传的是解包后的上游原始 URL(如 https://api.anthropic.com/v1/messages);
  • 学习侧:state.beforeSend(url, init) 传的是完整的 overlay URL。

recallLaneKey = origin + pathname(src/agent/conversation-recall.ts),两个 key 永不相等 → recallLaneHasEntries(claimKey) 恒 false → maybeNegotiatedClaim 直接短路。raw 通道两侧拿同一个 URL,所以只有它正常。原测试(tests/dsh-conversation-recall.test.ts)只覆盖 raw 形态(#3617 缺一行)。

改了什么

学习侧(maybeRecallBeforeSend)在算 lane key 前先过同一个 routedBiliModelUrl() 归一化:overlay URL 折叠回上游 URL,raw URL 原样通过(该函数对 raw 返回 undefined → key = 原始 URL)。不变式:同一逻辑 lane 的 learn key === claim key,raw / routed 两种形态都成立。只在学习侧归一化——认领侧拿到的已是解包一次的目标,再解一次可能重新劈开 key。

怎么验证

  • npm run typecheck 干净;
  • node --import tsx --test tests/dsh-conversation-recall.test.ts 4/4 绿:新增 routed 正向配对(overlay 学习 → 上游 URL 认领 → 命中并盖章,且 lanes === 1)+ 新增跨 lane 负向(不同逻辑 lane 带同样历史 → 拒绝);原有 raw 正向与 fork 负向不变仍绿;
  • 相邻文件 tests/conversation-recall.test.ts 5/5、tests/native-intercept.test.ts 64/64 绿。未跑全量。

@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-21_recall-routed-key (8981004)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4908-pr.4116.f8defe5

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4116.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei
ranxianglei merged commit a614d4e into master Oct 21, 2026
46 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.716-master.a614d4e (rolling master tag).

npm install -g billion-context@0.0.716-master.a614d4e  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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

Labels

None yet

Projects

None yet

1 participant