Repository navigation
[PR] Task sub-agent bili calls are no longer compressed into the parent session (#4580) | Task 子代理的 bili 调用不再压缩到父会话 (#4580) - #4978
Conversation
Claude Code 的 Task 子代理和主线程共用一个 MCP shim 进程:shim 启动时 抓的绑定只认主会话,而子代理的模型流量走的是代理里另一条 lane,于是子代 理的 compress 全部压到父会话上(refs 全 unknown/误折),或撞 witness 409 永久失败。 Claude Code ≥2.1.308 在每次 tools/call 盖 _meta["claudecode/toolUseId"]。 本改动三层: - tool-ring 新增 tool_use id → 会话 映射(TTL 10 分钟,容量 1024); - plugin 的每条响应管道在 witness settle 时同时记 id;工具路由阶梯最前 插入:id 命中且 lane 存活 → 直接路由(host-stamped 权威,同 #2024), 未命中回退旧阶梯,fail-closed 不变; - mcp shim 把 _meta id 转发为 body toolCallId(复用 agent/shared.ts 既有 字段),不动 routeOverride、不动全局绑定。 tests: issue4580-claudecode-tooluseid-routing.test.ts (12 例,记录/路由/shim)
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6527-pr.4978.eee7d4dThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4978.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 本 PR 是原 issue #4580(qiangu2020 报告:Claude Code Task 子代理的 bili MCP 压缩落到父会话)的实现——PR 正文「Fixes #4580」对应关系成立。相关但不同的在途/已立项条目:
标签: 开始审核:已拉取分支 |
Review of #4978: the capacity-eviction scan broke on its first entry — the early-exit condition is always true for the element that just set the running minimum — so eviction actually dropped the FIRST-INSERTED id regardless of age. A re-recorded id keeps its insertion slot while refreshing its timestamp, so position order is not age order. Remove the early break (full scan over a <=1024-entry map, only past the cap) and pin the intended behavior with a regression test that fails on the old code.
(ai: vllm-qwen/qwen3.8-27b) Merge-guard "behind" was stale — no action needed: branch |
(ai: vllm-qwen/qwen3.8-27b) 审核完成。独立重读了 PR 全量 diff、路由阶梯相邻代码与全部 settle 管道,本地在真实 head( 结构化八问
回归审查清单(diff 触碰路径的既有行为)
测试有效性12 例是真行为测试(真入口 审核发现并已当场修掉(1 处,commit
|
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.890-master.6ec0e97 # this exact build
npm install -g billion-context@master # always the newest merged build
|
修什么
Claude Code 的 Task 子代理和主线程共用一个 MCP shim 进程。shim 启动时抓的绑定只认主会话,但子代理的模型流量走的是代理里另一条 lane —— 结果子代理的 compress/搜索调用全部按父会话路由:refs 全 unknown、压错对象,或者撞上 witness 409 永久失败(issue #4580)。
怎么修(三层)
Claude Code ≥2.1.308 在每次 MCP tools/call 上盖
_meta["claudecode/toolUseId"](即本次调用的 tool_use 块 id)。代理是模型输出的唯一通道,出站时见过每个 tool_use 属于哪条 lane —— 两侧对上号,id 即 lane:toolCallId(复用 agent/shared.ts 既有字段)命中且 lane 存活 → 直接路由到该 lane(host-stamped 权威,同 Codex Code Mode 压缩失败:MCP shim 忽略每次调用的 _meta.threadId,错误使用过期 env ID #2024);未命中回退旧阶梯,fail-closed 语义不变。_metaid 转发为 bodytoolCallId,不动 routeOverride、不动全局绑定、不误标 nativeCaller。与 PR #4774 的关系
#4774 把无 header 的子代理切到独立 session lane(修 #4769/#4862 的根因)。本 PR 补的是它没覆盖的最后一环:lane 切分之后,共用 shim 的绑定仍指向父会话,子代理的 MCP 调用仍会路由错 —— 本 PR 用 host 盖的 id 直接路由。两个 PR 独立成立,可分别合并。
测试
Fixes #4580