Repository navigation
[PR] fix: split header-less claude code subagents onto their own session lane (#4352) - #4774
Conversation
…ane (#4352) Claude Code builds that stamp no agent-id headers (VS Code extension) send subagent model requests under the parent session id. Their short, unrelated histories ride the parent session and destroy its fold substrate: fold-reconcile sees covered ids missing, confirms epoch destruction, and the model's compress calls die as substrate-destruction with refs recorded DEAD. The #975 two-signal gate cannot see these subagents: VS Code builds share the parent's first system block verbatim, so the main-prefix negative check fails even when the agent-id headers are present. Route claude anthropic-wire traffic (x-claude-code-session-id source, evidence allowlist in the lane-decisions registry) through the continuity-aware order resolver when the #975 gate misses: a continuing main conversation keeps the raw id on order+content evidence; a history-disjoint ride forks onto its own |sub:<fp> lane (own lock chain, own compression state); a byte-drifted system on continuing history still keeps the raw id (#1106). Gated by the existing subagentSplit knob (no new config surface); side calls and empty-system requests stay verbatim. Re-applies the fix from unmerged PR #4409 (closed by a stale-ticket bot that misattributed the closure to #4337, which does not touch this path) onto current master. Closes #4769 (re-report of #4352). Tests: tests/issue4352-claude-anthropic-subagent-split.test.ts — both gate directions plus the live VS Code field shape captured in the issue comment. Docs: CONFIGURATION.md/.zh-CN.md subagentSplit rows describe both paths.
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。同机制条目只有 #4409(同标题,被 stale-ticket bot 误关未合并,误归因于不碰此路径的 #4337);本 PR 是它在当前 master(base 标签:bug / claude-code / scope/wiring / p1 —— 用 subagent 即永久毁掉父会话折叠基底(refs 记 DEAD 不可恢复)的缺陷;Claude Code native 车道;请求管道内会话路由;核心承诺失灵。 初判状态(独立审核进行中,结构化结论随后补):
|
(ai: vllm-qwen/qwen3.8-27b) PR 审核结论(独立审核,非引用 issue 侧分析)本地证据(worktree @ 20ebd2e,vs master bb7c249): 结构化八问
测试有效性8 个测试、正负双向齐全(符合 #3617 门禁纪律):allowlist 谓词单测(含 dsh/plugin 负行)、resolver 行级表(claim/fork/同车道复用/异 system 异车道/字节漂移 reanchor//compact 头重写)、现场形状钉死(共享首 block 仍分叉、burst 后父会话回原 key)、真实 startServer+mock SSE 的 e2e(父会话对象同一性 + stats 计数断言,有牙)、opt-out 行、豁免行。断言针对的是会话身份与计数,不是 HTTP 状态码恒真。 diff 整洁度8 文件 +439/−36,每一行都服务于本 PR 目的;文档中英同步;无空行/重排噪音;无锁文件/生成物。干净。 判定可合并——等 CI 在 head 20ebd2e 上转绿即可(当前 queued)。按 §7.4,会话身份绑定逻辑属 must-stay-human,合并请 owner 操作:#4774 |
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6521-pr.4774.c13ae5dThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4774.tgz
npm install -g packageInstall instructions are refreshed on each push. |
评审结论(先修第一批 · 自动评审)1. 这是啥问题? Claude Code(尤其 VS Code 构建)的子代理不带 agent-id 头,所有模型请求共用一个会话 id —— 子代理的短历史混进主会话,轻则父会话被错误回收、压缩永久拒绝,重则子代理请求 400。 2. 根本原因是啥? 3. 如何解决的? 核心 commit 4. 是否能合并? 暂不可合,需补两件事后可合:
5. URL:PR #4774;关联 #4769 / #4862 / #4580 / #4352。 合并后注意:#4774 落地会让 VS Code 子代理的 MCP 调用暴露 #4580 形态(此前共享会话碰巧落对),建议 #4978 与本 PR 同批发。 |
…ke veto (#2170) The header-less claude-code persona fork landed in src/server/handle.ts's anthropic ladder with a fresh !sideRequestLike conjunct. Per the #2170 lane-guard discipline a lane-symbol edit in handle.ts must land with a dedicated lane-suite pin. Row (K) is that pin, contrast-shaped: the same claude-code persona traffic with sideRequestLike=true (tiny tool-less budget, no agent header) stays verbatim on the raw key — counted nowhere, no persisted |sub ghost — while the full-budget shape rides the order resolver and forks its own |sub:<fp> lane.
(ai: vllm-qwen/qwen3.8-27b) Merge-guard sync done: merged origin/master into |
…nthropic-subagent-split # Conflicts: # tests/side-lane-invariants.test.ts
…gent-split' into 2026-10-26_claude-anthropic-subagent-split
|
补齐评审提出的两个阻塞项(9a4891f4):
CI 已在新 head 重跑,等全量矩阵结果。 |
(ai: vllm-qwen/qwen3.8-27b) 独立复核确认:head |
(ai: vllm-qwen/qwen3.8-27b) CI 判定(head 八问:
状态已报 #4599。PR 检查矩阵全绿,ready for human merge(head |
Unblocks PR #5004's test (windows-latest, 22, 2) red on head da25207: three abort cells (proxy-openai-sse / proxy-responses-sse / proxy-json) asserted closed=0 after exhausting the flat 3s (30x100ms) poll on a loaded Windows runner -- the same signature already recorded under #4599 for #4982/#4774/#4683 (rerun green / in-branch budget bump). Sibling cell abort x proxy-anthropic-sse passed in 176ms on the same shard and every other windows/ubuntu shard ran this file green on the same head, so this is runner load, not a code regression; the PR's diff touches none of these paths. Labeled CI-unblock commit; duplicates #4683's pending identical change -- drop this commit when rebasing if #4683 lands first.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.889-master.1a2f5b8 # this exact build
npm install -g billion-context@master # always the newest merged build
|
…aw session id (#5136) Claude Code CLI fires its session-title call ~1ms ahead of the first main turn under the SAME x-claude-code-session-id. Since #4774 (v0.1.209) that header-less traffic rides the persona order resolver, and the title call — own system prompt, single <session>-wrapped user blob, no tools, budget past the <=200 heuristic — claimed the raw id as kernel anchor on the virgin id; the main turn then arrived tagChanged and history-disjoint and forked onto a |sub:<fp> lane for the session lifetime (#2156 form: side requests must never claim the anchor). New shape predicate isClaudeCodeTitleRequest in src/server/side-request.ts (no-tools veto + exactly one user entry whose text starts with the <session> wrapper), wired into both lane gates in handle.ts behind the claude-code conversation-source evidence gate: sideRequestLike keeps it off the resolver (verbatim iding) and sideIntent routes it through the #388 passthrough (kernel state untouched). Precedents: #2503 dsh title, #4438 dsh auto-review. Tests: tests/issue5136-claude-title-sidecar.test.ts (predicate truth table + live race in both arrival orders + client-evidence negative; verified to fail against the pre-fix wiring) and row (M) in tests/side-lane-invariants.test.ts (#2170 lane-guard pairing).
Re-applies the fix from unmerged PR #4409 onto current master. It was closed by a stale-ticket bot that misattributed the closure to #4337 (pi incremental ack + storage drift fallback), which does not touch this path. Verified on master
bb7c2497/ v0.1.208 that the #4409 code (personaOrderKeyed,claudeAnthropicPersonaOrderApplies) is absent fromsrc/andtests/— the bug is live.What / why
Claude Code builds that stamp no agent-id headers (VS Code extension,
entrypoint claude-vscode) send subagent model requests under the PARENT session id. Their short, unrelated histories ride the parent session and destroy its fold substrate: fold-reconcile sees covered ids missing, confirms epoch destruction, and the model'scompresscalls die assubstrate-destructionwith refs recorded DEAD forever. The parent conversation is intact — no compaction ever happened.The #975 two-signal gate cannot see these subagents: in the live transcripts (#4352 comment; extension 2.1.307) the parent and ALL subagents send the SAME first system block verbatim ("You are Claude Code, …Claude Agent SDK."), so the main-prefix negative check fails even when the agent-id headers ARE present. Separation must come from order+tag evidence, not prefix heuristics.
Fix
Route claude anthropic-wire traffic through the continuity-aware order resolver (#2944/#2241 — the same one dsh / codex / claude-over-Responses already use) whenever the #975 gate misses:
x-claude-code-session-id— newpersonaOrderKeyedflag on the WIRE_CLIENTS registry entry + new predicateclaudeAnthropicPersonaOrderApplies(src/session-id.ts). Every other anthropic client stays verbatim (Responses instructions fingerprint should be an allowlist (codex/claude only), not a default — generic relay clients fork on every system-prompt change #1106).<id>|sub:<fp>lane: own lock chain, own compression state, stable across successive passes of the same persona; distinct subagent systems get distinct lanes.subagentSplit: falseall stay verbatim exactly as before.Behavior change (old → new)
|sub:<fp>lane.system prompt changed (11170 → 3044)→ drop → epoch →substrate-destructionchain stops firing during subagent runs; the model'scompresson parent ranges stays anchorable; refs are no longer recorded DEAD.Config surface
NO new field. The existing
subagentSplit(BILI_SUBAGENT_SPLIT) semantics are EXTENDED:falsenow also disables the header-less order-resolver fallback (previously it only disabled the #975 header-pair split). Default stays ON. Rationale for not inventing a second knob: the two paths are one mechanism family ("keep claude subagent traffic off the parent session"), one escape hatch is enough. Docs updated in CONFIGURATION.md + CONFIGURATION.zh-CN.md.Both-modes reasoning
Session-keying only — no wire rewrite, no tool/nudge/summary-carrier change. Plugin mode (any
x-bili-pluginhost) is untouched: the new branch fires only when the winning conversation source IS the claude header, which plugin lanes never are (they stampx-bili-plugin-conversation, first in the source precedence). Proxy-mode claude native traffic (the affected one) runs the standard server-side compression pipeline; the forked subagent lanes simply run it under their own session state.Regression review (existing behaviors walked)
x-acp-sessionetc.) — verbatim identity preserved; negative e2e row in the new suite.Tests
Targeted local runs (full-suite verdict = remote CI on the pushed head):
npm run typecheckclean.No
kernel/changes. No config-schema or persistence-format change. Touches identity/session-binding logic → human review per §7.4.Closes #4769 (re-report of #4352). Related: #4409 (the original fix, closed unmerged), #4580 (MCP-side binding, separate mechanism).