Skip to content

[PR] feat(session): split Claude Code SDK subagents into isolated session lanes - #5726

Open
feriaref wants to merge 10 commits into
ranxianglei:masterfrom
feriaref:feat/claude-subagent-session-lanes
Open

feriaref wants to merge 10 commits into
ranxianglei:masterfrom
feriaref:feat/claude-subagent-session-lanes

Conversation

@feriaref

@feriaref feriaref commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

Two session-isolation defects in src/session-id.ts for Claude Code 2.1.308+ / Claude Agent SDK, plus one field-evidenced face of the same mechanism family found during review (#6011):

  1. SDK subagent turns classify as main. SDK subagents lead their system blocks with "You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK." — the main-session classifier matched any block starting with "You are Claude Code", so claudeSubagentAgentId returned undefined for every SDK subagent turn and that traffic collapsed onto the parent session's lane (Subagent first token stalls 1-2min: withSessionLock covers full forward + slow flash upstream first byte #970's split never fired for SDK subagents).
  2. Long shared <system-reminder> prefixes collide in anthropicFirstUserFrag. For headerless / parent-header-only subagents, the derived-persona lane key uses a 1024-char fragment of the first user message as discriminator. Claude Code prepends shared <system-reminder>…</system-reminder> blocks (CLAUDE.md / codebase context, often >1024 chars) before the actual task prompt — so concurrent subagents with distinct tasks produced identical fragments and shared one compression lane.
  3. Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011 field shape: the first user message is ENTIRELY shared boilerplate. Field log (bili v0.1.213, 3 days, cited in Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011): three concurrent same-type CC SDK subagent runs carried a BYTE-IDENTICAL first user message (shared CLAUDE.md preamble, 894 chars — below the cap, so no truncation divergence), diverging only from msg#4 on. The D1-B fragment was equal across all three → they collided onto ONE lane (weighted cache hit 68.7% vs 95.0% for the main session; every pass clobbered the shared skeleton). Stripping reminders alone cannot fix this face: when the whole first message is boilerplate (with or without reminder wrappers), there is nothing run-distinguishing left to slice.
  4. Field capture (CC 2.1.326 / Claude Desktop, Claude Code SDK subagents match MAIN_SYSTEM_PREFIXES and long shared <system-reminder> blocks collide in anthropicFirstUserFrag #5724 thread): main and subagent turns share the SAME identity block — both lead with the SDK harness banner — so text-only discrimination depends on the banner's exact wording surviving rewording. The capture shows the host already declares the channel explicitly in request headers (x-claude-code-request-class: subagent | blocking-subagent | main, plus the x-claude-1p-request-class twin): protocol, not prose.

What changed

  • claudeSubagentAgentId: a CHANNEL-HEADER layer above the text signals — x-claude-code-request-class (falling back to the x-claude-1p-request-class twin) subagent / blocking-subagent → split on agentId ?? parentId, main → main session, absent or unrecognized value → fall through to the text rules below. The header keeps the split alive if the banner is ever reworded, and an explicit main short-circuits before any system text is read. Trust note: the headers are client-controlled in proxy mode, but the key they shape is namespaced by the sender's own session id — a spoofed class can only fragment the sender's own traffic (same trust class as x-claude-code-session-id itself).
  • claudeSubagentAgentId: skips the exact SDK harness banner (CLAUDE_SDK_HARNESS_BANNER) before the main-prefix scan — it is shared harness state present on EVERY SDK turn (main and sub alike), so it carries no classification signal. Exact-prefix exclusion (not substring) means a reworded banner degrades back to pre-SDK serial behavior instead of mis-splitting a real main turn whose text merely mentions the phrase. Adds "You are an agent working with the user toward their goals" (the SDK main-session marker) to MAIN_SYSTEM_PREFIXES; keeps "You are Claude Code" for interactive CLI sessions.
  • anthropicFirstUserFrag: strips leading <system-reminder>…</system-reminder> blocks before the 1024-char cap; ADVANCES past user messages that are reminders-only (no run-distinguishing material survives stripping) to the next user message that has material; falls back to the raw text of the FIRST reminders-only message only when nothing later has material either. Reminder-strip output is stripped-only; the fallback moved into the caller.
  • New anthropicLaterUserFrag + resolver collision-widening (Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011): skips the first user message with extractable text (its material feeds the base fragment) and joins up to 4 LATER user messages, each reminder-stripped and capped at 512 chars — CC grows early shared messages by tail append past the cap, which keeps a settled lane's key byte-stable. resolveSessionOrder gains a trailing laneWideDiscriminator param (source-compatible; only the claude-anthropic call site passes it). In the derived-persona fork branch: when a non-empty wide discriminator rides the request AND an occupant skeleton already sits under the base fork key that the incoming does NOT continue — neither a strict prefix EXTENSION (growth / equal retry) nor a fragment-verified TAIL continuation (native compaction / head truncation keep the living tail verbatim — the exact mirror of the existing tag-less re-anchor rung) — the key widens to a fourth segment <base>:<fp16(wide)>: the incoming records under its OWN widened key and the occupant's skeleton survives untouched.
  • Tests: SDK sub/main system shapes, banner-alone, parent-header-only fallback, a main block that mentions the SDK phrase (must NOT split), frag collision plus edges (string path, reminders-only fallback, no-reminder byte-identical pin); Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011 field-shape rows (first arrival plain key, colliding run widens, equal-retry stable, occupant growth NO rename, widened run stays isolated as its window grows, compaction one-time re-key) plus negative control (distinct first-user frags → byte-identical pre-change keys) and degradation control (absent/empty wide arg → exactly today's behavior).

Behavior change (old → new)

  • NEW (channel-header layer): requests carrying x-claude-code-request-class / x-claude-1p-request-class are now classified by that declaration — main stays on the main lane even with an agent-id header and subagent-shaped system text (previously decided by the text scan); subagent / blocking-subagent split even when the banner is reworded (previously collapsed onto the main lane). Requests WITHOUT these headers are byte-identical to before.
  • SDK subagent turns now split onto <id>|sub:<agent-id> (previously rode the parent lane).
  • SDK main-shaped systems ("You are an agent working with the user…") stay on the main lane; interactive CLI / -p / legacy subagent shapes are byte-unchanged.
  • anthropicFirstUserFrag values change for reminder-prefixed AND reminders-only-first-message inputs → affected derived-persona lanes rename once on upgrade (cold start on the new lane, no data loss); reminder-free output with a non-boilerplate first message is byte-identical to before.
  • NEW (Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011): concurrent same-type subagent runs sharing a byte-identical first user message now land on DISTINCT four-segment lanes on collision (previously ONE shared lane, mutual skeleton clobbering). Healthy runs (distinct first-user fragments) never contest a base key and keep byte-identical pre-change keys. Stability properties: a run arriving with ≥4 later user messages (the field shape) is stable from its first pass; a shallow fresh run can re-key at most 4× while its first four later-user messages accumulate, then freezes. Residuals: (a) if a run's first 4 later user messages are ALL shared across runs, the widened fingerprints are equal and the collision persists (far narrower than today's universal collision); (b) native compaction of any D1-B run re-keys once onto the fresh base fragment (pre-existing behavior class — the base fragment follows the first user message by Claude Code sub-agents of the same type share a single compaction lane: unrelated sessions bleed content into each other | Claude Code 同类型子代理共用一条压缩车道:无关会话互相串内容、折叠暂停;旧版共享父 id 的折叠块升级后仍残留在父会话 #5095 contract); (c) a stale shorter replay of an occupant takes the widened key until the client catches up (self-heals; strictly better than today's clobber-and-rewind).

Verification

Fixes #5724

…lanes

When the Claude Agent SDK spawns a fresh subagent inside the same workspace,
both parent and child inherit the same working directory and omit
user_id:session_... metadata, but start with different system prompts and first
user prompts. Without an agent-level discriminator in the fallback session hash,
concurrent subagents collide onto the parent's session lane and trigger
prefix-drift resets.

- Extract the Claude Agent SDK subagent system prompt header via
  claudeSubagentAgentId and include it in the Anthropic fallback hash when
  explicit session metadata is absent.
- Include the opening user message fragment via anthropicFirstUserFrag when no
  explicit session_id or subagent header is present, while keeping custom
  system prompts out of the fallback key so mid-session system prompt edits do
  not split the session.

Fixes ranxianglei#5724
@feriaref
feriaref force-pushed the feat/claude-subagent-session-lanes branch from ba5777c to 70f5515 Compare November 5, 2026 07:46
@ranxianglei ranxianglei changed the title feat(session): split Claude Code SDK subagents into isolated session lanes [PR] feat(session): split Claude Code SDK subagents into isolated session lanes Nov 5, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。open [PR] 条目与镜像检索中均无其他针对「Claude Code SDK subagent 会话分裂 / 判别片段碰撞」的条目;本 PR 正对应上游 issue #5724(同一机制:① SDK subagent 的 system 块以 "You are Claude Code…" 开头,被 MAIN_SYSTEM_PREFIXES 误判为主会话而不分裂;② 共享的长 超过 1024 字符时,anthropicFirstUserFrag 先切片后剥离,两个并发 subagent 得到相同判别片段而撞车道)。

标签: bug、claude-code、scope/wiring、p2(并发 SDK subagent 撞进父会话车道触发 prefix-drift reset;能用但有明显问题,未达数据丢失/不可用级别)。

初审已启动,方向判断:两处修复都打在产生缺陷的判定点上(claudeSubagentAgentId 的主会话判定 + frag 切片的剥离时机),diff 干净(仅 src/session-id.ts 与其测试文件),base 即最新 master。正在本地跑定向测试并等 CI 全量套件,详细审核报告(八问体例)随后补。

ranxianglei pushed a commit that referenced this pull request Nov 5, 2026
Regression pins for the new stripLeadingSystemReminders behavior added by this PR:
- reminder-only first user message degrades to the original text (no empty discriminator)
- an unclosed leading <system-reminder> tag is never stripped (no data loss)
- multiple consecutive leading reminders are all stripped
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

审核完成(独立重审,未照抄 issue 结论;核对了 PR 两个 head:初版 70f5515 与你后来合入 ci-fixes 的 97bc3dd——后者只动了 6 个 dsh 测试文件,本 PR 核心文件逐字节未变,初审结论对新 head 同样成立)。

既有行为回归清点(逐项)

既有行为 结论
旧版交互式 CLI 主会话("You are Claude Code, …"无 SDK 标记) 保持:特例条款仍判为主会话,不分裂
-p/print 模式主会话("You are an interactive agent…") 保持:前缀未动
2.1.308 以前的 subagent 形状(background job / file search specialist / 自定义 agent) 保持:不含 "You are Claude Code" 块,负向判定路径未变,照旧分裂
#970 双信号门(agent-id/parent-agent-id 头 + 负向主判定)、<id>|sub:<agent-id> 命名空间映射、subagentSplit:false 退出开关 保持:门条件与命名空间逻辑未触碰,现有 harness 测试(split / no-stall / gate-off)本地通过
显式 user_id:session_… / x-claude-code-session-id 路由、OpenAI/Responses 车道、kernel 未触碰(diff 仅 src/session-id.ts + 其测试)
frag 的消费面(#4352/#5095 headerless 车道,handle.ts:1193) 单会话内首条 user 消息跨轮重发不变 → 键跨轮稳定,会话中途不漂移

行为变更披露(旧值→新值+原因)

  1. SDK subagent 分类:旧=被误判主会话不分裂(Claude Code SDK subagents match MAIN_SYSTEM_PREFIXES and long shared <system-reminder> blocks collide in anthropicFirstUserFrag #5724 缺陷本身)→ 新=分裂到 |sub:<agent-id>。即修复目标。
  2. SDK 主会话的主判锚点:旧=靠 block-1 "You are Claude Code" 前缀 → 新=靠 block-2 "You are an agent working with the user toward their goals"(block-1 因含 "running within the Claude Agent SDK" 被排除)。净效果不变(仍判主),但依赖的字符串换了——若未来 CC 版本改这段措辞,SDK 主会话会被误判为 subagent。残留风险,已用 2.1.308 实流量形状测试钉住,与既有「按捕获的前缀做负向判定」的设计哲学一致。
  3. frag 判别内容:首条 user 消息以 <system-reminder> 开头时,旧=前 1024 字符含 reminder 正文 → 新=剥掉全部前导 reminder 后取 1024(剥完为空则回退原文,避免空判别符)。同一会话内前后稳定;但存量运行中的此类 headerless 会话在代理升级后车道键迁移一次,该车道压缩状态重启一轮(一次性代价,仅限 Subagent requests share the parent session id and trip fold-reconcile #4352/Claude Code sub-agents of the same type share a single compaction lane: unrelated sessions bleed content into each other | Claude Code 同类型子代理共用一条压缩车道:无关会话互相串内容、折叠暂停;旧版共享父 id 的折叠块升级后仍残留在父会话 #5095 headerless 车道)。这是碰撞修复的固有成本——任何判别器变更都会挪键。附带细节:剥离函数对不匹配内容也会 trim 首尾空白,键空间影响可忽略且会话内稳定。

代码与测试审查

  • 两处修复都打在产生缺陷的判定点上(主判谓词 + 切片/剥离时序),不是症状层过滤 ✓
  • 正则安全:惰性匹配+要求闭合标签,未闭合标签永不剥离;全 reminder 消息回退原文 ✓
  • MAIN_SYSTEM_PREFIXES 为模块私有,无外部消费者 ✓
  • 测试有牙:SDK subagent 分裂/SDK 主带 agent-id 不分裂双向覆盖;碰撞测试在旧代码上会真失败(两边同取相同 reminder 的前 1024 字符)✓
  • review 发现的小缺口已直接补上:新增剥离逻辑的三个边缘用例(reminder-only 回退原文 / 未闭合标签不剥离 / 连续多 reminder 全剥)原测试未钉住。因 PR head 在你的 fork 上我没有写权限,commit 放在上游仓同名分支:ranxianglei/billion-context@feat/claude-subagent-session-lanes(sha 41b5e0b,基于当前 PR head 97bc3dd + 该测试 commit,本地 7/7 绿 + tsc clean)。取用:git fetch https://github.com/ranxianglei/billion-context.git feat/claude-subagent-session-lanes && git cherry-pick 41b5e0b;不需要的话告诉我删掉该分支即可。

CI

static-gates 全绿;97bc3dd 的全量矩阵截至最后一次快照无失败、其余分片仍在跑。你合入的 ci-fixes 遵循 #4599 继承红处理流程,与本 PR 核心无关,处置正确。

结构化八问

  1. 是什么问题:Claude Code 2.1.308+/Agent SDK 并发 subagent 撞进父会话车道,触发 prefix-drift reset。
  2. 什么原因导致的:主会话判定是正向前缀匹配但未排除 SDK 变体标记(SDK subagent 与主会话共用 "You are Claude Code…" 开头);frag 判别器先切片后剥离,共享前导 reminder 超过 1024 字符时判别信息被截断归零。
  3. 影响范围与严重程度:用 Claude Agent SDK 或 CC 2.1.308+、并发跑 subagent、且不带显式 session 元数据的场景;后果是压缩状态重置/subagent 间串扰(效率损失、互相干扰),会话仍可用 → p2。
  4. 怎么修复的:主判谓词加 SDK 标记排除条款并补 SDK 主识别前缀;frag 改为先剥前导 reminder 再取 1024,剥空回退原文。
  5. 是否有回归问题:见上方逐项清点——既有行为全部保持,三处有意变更已披露;无 fail-fast 变吞错、无阈值/时序/输出格式漂移。
  6. 是否破坏缓存:模型侧前缀缓存不受影响(只改 bili 内部会话键推导,出站字节不变);bili 内部仅受影响 headerless 会话一次性键迁移(披露 3)。
  7. 是否改了设计方向:没有。仍是双信号负向判定 + 证据白名单纪律,只是按新流量形状补排除条款。
  8. 是否引入了新的配置:没有。

收工判定:方向正确、diff 干净、回归面受控且已披露、测试有牙——CI 全绿后可合。注意此项触碰会话身份绑定逻辑,按 AGENTS.md §7.4 属人工审批范畴(不适用自动合并),合并由你来。建议合并时连同边缘测试 commit(41b5e0b)一起带上。

ci-check added 2 commits November 5, 2026 18:16
…main-session evidence

Convergence of review finding on this PR: the substring check
(!includes("running within the Claude Agent SDK")) could mis-split a REAL
main session whose interactive block merely mentions that phrase later in
its text, violating the ranxianglei#970 invariant that a main session can never be
mis-split. The banner is now excluded by exact prefix match
(CLAUDE_SDK_HARNESS_BANNER), and "You are Claude Code" is restored to
MAIN_SYSTEM_PREFIXES so a reworded banner degrades back to the pre-SDK
serial behavior instead. Adds regression rows pinning: main block that
mentions the phrase stays main, banner-alone carries no main evidence,
SDK subagent with parent header only falls back to the parent id.
Covers the rows the original PR left open: string-content path strips the
leading reminder, a reminders-only message falls back to the ORIGINAL text
(spec: never ""), and reminder-free output stays byte-identical to the
pre-strip behavior so the common case cannot silently drift.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI 修复完成:PR 代码无缺陷,最后一处红是已知 flaky 测试,需一次 re-run。

上一轮(head 70f5515):10 个测试分片全红 = 继承 master 出生即红集群(#5687 合入后 6 个 dsh/persona/watermark 回归钉转红)+ 1 个 Windows 文件锁 flake。按 CI 协调政策把 origin/ci-fixes(0470bec,仅重对齐 6 个测试钉)merge 进 PR 分支并推送,新 head 97bc3dd。

本轮(run 42005243832,head 97bc3dd):25/26 全绿 —— 全部静态门禁/守卫绿,9/10 测试分片绿,上一轮的 Windows EBUSY flake 未复发。唯一红:test (ubuntu-latest, 22, 2)。拉取该分片日志定位:3179 个测试中恰好 1 个失败 —— msgid lane flow: pin carries client ids into rows; edits append fresh rows(tests/msgid-lane-flow.test.ts:139,期望 4 行实际 3 行)。该签名与 #4599 floor 956 记录的已知 node22 时序 flake 完全一致(上次在 Windows shard5,这次 Ubuntu shard2)。本地在合并后的 head 上连跑 3 次:全部 6/6 绿。

八问:

  1. 是什么问题:PR 自身代码没有问题;最后剩下的红是 msgid 增量车道回归测试里一个时序敏感的断言偶发失败。
  2. 什么原因导致的:flaky 测试——同一测试在不同 runner 上时红时绿(CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 floor 956 已记录同文件同平台族);本地连跑 3 次全绿;与本 PR diff 无关(PR 只动 src/session-id.ts 和它自己的测试文件,完全不碰 msgid 车道)。
  3. 影响范围与严重程度:只影响本 PR 的 check 矩阵(偶尔也会咬到别的 PR);无用户面影响;属 CI 信号可靠性问题(p3 级)。
  4. 怎么修复的:无可修代码——flake 硬化属 master 级测试基建,按政策收敛到 ci-fixes/哨兵车道,不在本 PR 分支重复修;已在 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 记一行供哨兵跟踪。
  5. 是否有回归问题:无。逐项核实:ci-fixes diff 只碰 6 个测试文件,与 PR 的 2 个文件零重叠;merge 前在本地复现了同样的红(issue2817、issue2419 guard-stamp),merge 后 7 个相关文件全部本地绿(含 PR 自己的 claude-subagent-split 6/6)。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:无。
  8. 是否引入了新的配置:无。

判定:PR 可合——点一次「Re-run failed jobs」清掉 flake 即可(或任何后续 push 自动带跑)。无需设计决策,未开新 issue。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: vllm-qwen/qwen3.8-27b)

APPROVE —— 独立复审通过(未照抄线程内已有审核评论;对最终 head f83648e 重新核对了全部关键路径与证据)。

独立核对范围

  • 作者 commit(70f5515)与两个收敛 commit(e0547f5 banner 精确前缀化、f83648e frag 边界测试行)逐段读过;ci-fixes 合入(97bc3dd)做了逐文件 blob 比对 = 纯合并,仅动 6 个 dsh/watermark 测试钉,核心文件零改动。
  • 双信号门语义全量推演(交互式 CLI 主会话 / -p 主会话 / SDK 主会话 / SDK subagent / <2.1.308 旧 subagent 形状 / 仅 parent header / 无 header 流量):各路径要么与既有行为逐字一致,要么按预期修复;banner 未来改词时退化为「subagent 停止分裂」的 pre-SDK 串行行为,不会误拆主会话——降级方向安全,且已写入注释。
  • anthropicFirstUserFrag 在仓库内只有一个调用点(server/handle.ts 的 D1-B 回退判别,仅 claude-responses identity 可达,用于 fork 键加宽):剥离 reminder 后同一 subagent run 内首条 user 消息不变 → 车道键 run 内稳定;reminder-free 输出逐字节不变(有测试钉住)。
  • 测试有效性:碰撞用例与 SDK-sub 分裂行在修复前必红,是真回归钉;字符串路径 / 仅-reminder 回退原文 / 无 reminder 逐字节三行补上了原 PR 缺的边界;正负双向齐全(#3617)。
  • CI:head f83648e 镜像缓存 30/30 绿(0 failed / 0 pending,含 typecheck/static-gates 与 ubuntu+windows × node22/24 全部分片)。
  • 合规面:无 kernel/ 触碰(无需 kernel-change 声明)、无配置面/env 新增、无 version 改动、ACP 标签 hex 转义合规、PR 正文 Behavior change(old→new)披露完整(frag 重键一次冷启动、无数据丢失)。

遗留小疵(不阻塞):tests/claude-subagent-split.test.ts 文件末尾多一个空行(EOF 处 });\n\n)——纯外观问题,为它单独再烧一轮全量 CI 不成比例,留待后续任意触及该文件的提交顺手清掉。

结论:可合并(merge 由人执行)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

review-worker-r1 收工:对最终 head f83648e 完成独立复审(未照抄线程内已有结论——ci-fixes 合入逐文件 blob 比对确认纯合并、双信号门全人群语义推演、frag 唯一消费点核对、测试计数与正文声明核对 7/7+13/13),已提交正式 APPROVE review:pull/5726#pullrequestreview-5783921248。CI 镜像缓存 30/30 绿(0 failed/0 pending)。两个不阻塞的尾巴:① tests/claude-subagent-split.test.ts 文件尾多一个空行(纯外观,没为它再烧一轮全量 CI);② 前序 reviewer 留在上游仓的临时分支 feat/claude-subagent-session-lanes(41b5e0b,含未闭合标签/连续 reminder 两条额外边缘钉)已被 PR head 完全取代,可删——若想保留那两条额外测试钉,现在补 push 会再触发一轮全量 CI,由你定夺。合并等你执行(§7.4 会话身份逻辑属人工审批范畴)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

review-worker-r1 收工确认(补前缀正式收口):本 lane 对 PR 最终 head f83648e 完成了独立复审——逐段读了作者 commit 与两个收敛 commit、ci-fixes 合入做了逐文件 blob 比对(纯合并)、双信号门全人群语义推演(交互式 CLI / -p / SDK 主 / SDK subagent / 旧版形状 / 仅 parent header / 无 header)、frag 唯一消费点核对、测试计数与正文声明核对。结果:已提交正式 APPROVE review(pull/5726#pullrequestreview-5783921248),CI 镜像缓存 30/30 绿,无 kernel/ 触碰无需决策升级。遗留不阻塞项两条(测试文件尾部空行、前序 reviewer 的临时分支 41b5e0b 可删)已在上条说明。合并等你执行。

ci-check added 4 commits November 9, 2026 17:53
…t runs (ranxianglei#6011)

The ranxianglei#5726 D1-B discriminator is not injective over concurrent same-type
runs whose first user message is byte-identical shared boilerplate
(ranxianglei#6011 field evidence: three CC SDK subagent runs, identical 894-char
msg#1, diverging from msg#4+ — all three collided onto ONE lane at 68.7%
cache hit vs 95% main). Two cooperating changes:

1. anthropicFirstUserFrag advances past user messages that carry nothing
   but leading <system-reminder> blocks (stripping leaves no
   run-distinguishing material there); the raw text of the FIRST
   reminders-only message stays the degradation floor when nothing later
   has material either. Reminder-strip output is now stripped-only; the
   fallback moved into the caller.

2. New anthropicLaterUserFrag: skips the first user message with
   extractable text (its material feeds the base frag) and joins up to 4
   LATER user messages, each reminder-stripped and capped at 512 chars
   (CC grows early shared messages by tail append past the cap, keeping
   settled lanes byte-stable), joined with an ambiguity-free separator.
   resolveSessionOrder gains a trailing laneWideDiscriminator param
   (source-compatible): in the derived-persona fork branch, when a
   non-empty wide discriminator rides the request and an occupant
   skeleton already sits under the base fork key that the incoming does
   NOT continue — neither a strict prefix extension (growth / equal
   retry) nor a fragment-verified tail continuation (compaction keeps
   the living tail verbatim, mirroring the tag-less re-anchor rung) —
   the key widens to a fourth segment <base>:<fp16(wide)>: the incoming
   records under its own widened key and the occupant's skeleton
   survives untouched. Healthy runs never contest a base key and keep
   byte-identical pre-change keys; every other caller omits the arg.
- anthropicFirstUserFrag: advance past a reminders-only first user
  message to the next run-distinguishing one; advance across several
  uninformative messages with the first-raw floor winning when nothing
  later helps.
- anthropicLaterUserFrag: skip-first semantics, 4-segment join, 512-char
  per-segment cap, separator, empty-body cases.
- resolver field shape (ranxianglei#6011): byte-identical first-user boilerplate
  across same-type runs — first arrival keeps the plain three-segment
  key, the colliding run widens onto its own fourth segment (stable on
  equal retry), growth of the occupying run extends its own skeleton
  without rename, the widened run stays isolated as its window grows,
  and compaction re-keys once onto the fresh base frag (pre-existing
  ranxianglei#5095 behavior class) without colliding back.
- negative control: healthy runs with distinct first-user frags take
  byte-identical pre-change keys (no widening segment ever appears).
- degradation control: absent/empty wide discriminator reproduces
  exactly the pre-change behavior, collision included.
…6011 wide-discriminator + ranxianglei#5719 msgIds)

Conflicts in src/session-resolve.ts (signature + wrapper) and src/server/handle.ts (anthropic call site): both sides appended optional trailing params to the same functions. Resolution keeps master's layout canonical (msgIds, readStoredMsgIds) and appends the PR's laneWideDiscriminator LAST, so every master call site/test stays source-compatible; only the PR's own ranxianglei#6011 test call sites move their wide arg to position 9.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Merge conflict resolved. Master had moved ~403 commits past the PR base while the branch sat green-and-waiting, which put the PR into dirty. I merged master into the PR branch (on the fork, plain pushes — no force-push) and resolved two genuine conflicts.

What conflicted: both sides independently grew the same functions with new trailing optional parameters, and git cannot auto-union two differently-edited parameter lists:

Resolution rule: master's layout is canonical (trunk already shipped it and its tests call it positionally), so the merged signature keeps msgIds, readStoredMsgIds in place and appends the PR's laneWideDiscriminator LAST. Every master call site/test stays source-compatible untouched; only the PR's own five #6011 test call sites move their wide arg to position 9. Doc comments reconciled to match the final order.

Process notes: master moved AGAIN mid-run (#6015 landed, 406193b → 63a4060, visible through the shared refs store), so I integrated a second time — that delta was 8 notice/web files, zero overlap, clean auto-merge. Local node_modules had been wiped between rounds; restored via npm ci and rebuilt kernel 0.0.189 + pi-subagents dists before verifying. Push-discipline followed: re-fetched the fork head before every push, both pushes fast-forward (bd0527cd8b..77a5c9e99f, then 77a5c9e99f..fd0696798f).

Verification (both merges): full typecheck clean; targeted seam tests 46/46 green — PR side: tests/issue4352-claude-anthropic-subagent-split.test.ts (#6011 widening incl. negative control + degradation) and tests/claude-subagent-split.test.ts; master side: tests/issue5719-msgid-lane-identity.test.ts, tests/issue5719-self-checkpoint-reanchor.test.ts, plus tests/msgid-lane-flow.test.ts sanity. Re-ran the whole set after the second merge: same result.

Live state now: head fd0696798f0b contains ALL of current master (63a40600e75f); API confirms mergeable: true, mergeable_state: blocked = required checks pending on the new head, no conflict left. Per #4599, master is green and already absorbed the five-pin realignment (ci-fixes era ended), so the new CI run should not inherit reds; the known msgid-lane-flow settle-race flake family is still the one thing that may bite a random shard, and that belongs to the sentinel lane, not this PR.

八问:

  1. 是什么问题:PR 分支与 master 冲突(分支点之后 master 前进了约 403 个提交),GitHub 判 dirty、无法合并。
  2. 什么原因导致的:两侧各自独立扩展了同一组函数的「尾部可选参数」——master 侧 [resolveSessionOrder] Full compaction and persona tag drift occurring in the same turn → inevitably forks to |sub: side | [resolveSessionOrder] Full compaction and persona tag drift occurring in the same turn → inevitably forks to |sub: side | [resolve… #5719 加了 msgIds+readStoredMsgIds,本 PR 侧 Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011 加了 laneWideDiscriminator;git 无法自动合并两份各自改动的参数表。
  3. 影响范围与严重程度:只影响本 PR 的可合并性;无用户面影响;不解决则 PR 永久卡在 dirty(阻塞合并)。
  4. 怎么修复的:把 master merge 进 PR 分支(两次——工作进行中 master 又落地了 [PR] 2026 11 09 iot incompat notice upstream #6015);冲突解法 = 以 master 的参数布局为准、PR 的新参数追加在最后,master 侧全部既有调用点/测试零改动保持源码兼容,只调整 PR 自己 Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011 测试文件里 5 处调用点的 wide 参数到第 9 位;文档注释同步修正。
  5. 是否有回归问题:无。全量 typecheck 干净;覆盖接缝两侧的定向测试 46/46 绿(PR 侧 Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011 加宽套件含负对照+降级例、claude-subagent-split;master 侧 issue5719 msgIds 套件 ×2 + msgid-lane-flow),第二次 merge 后整套复验一致;合入内容仅为两侧变更之并集 + master 自身提交,无语义漂移。
  6. 是否破坏缓存:不涉及(会话键格式未变:健康运行保持逐字节相同的键,本次仅改参数传递顺序)。
  7. 是否改了设计方向:无。
  8. 是否引入了新的配置:无。

判定:冲突已清除,PR 回到可合并状态(等新 head 的 CI 跑完即 clean);无需决策,未开新 issue。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

✅ CI engineer run complete — full conflict-resolution report is the comment directly above (English narrative + 八问). One-line outcome: PR #5726's dirty state is cleared — master merged into the branch (twice; #6015 landed mid-run), two parameter-list conflicts resolved with master's layout canonical, pushed as fd0696798f (fast-forward, no force-push). Live API confirms mergeable: true, mergeable_state: blocked = required checks pending on the fresh head, no conflict left. Verification: typecheck clean + 46/46 targeted seam tests green after each merge. Nothing further needed from this lane until the new CI run lands.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

📡 CI status update (mirror cache, fetched 11:11 UTC): the fresh run on head fd0696798f is in flight — 5 success / 6 in progress / 8 queued / 0 failed so far (11 lane-specific jobs correctly skipped for this diff). No reds of any kind yet; nothing to fix or decide. This lane stays idle until the run completes — if the known msgid-lane-flow settle-race flake bites a shard, that goes to #4599 sentinel tracking, not back to this PR.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: vllm-qwen/qwen3.8-27b)

Round-2 review of final head 4c1559cb3

Independent end-to-end re-review after the PR gained two commits beyond my previously approved head (f83648e77) — the #6011 collision-widening fix and its tests — plus two master merges and one whitespace-only fix from this round (receipt below). All verification below was done fresh at the git level on this head.

Verification performed

  1. Merge purity. Both merge commits (77a5c9e99, fd0696798) proven pure: each merge result vs the current master tip diffs to exactly the PR's five files (+464/-55) — zero conflict-resolution drift. Kernel/ changes inside the window belong to master's own merges (#5971/#5949/lock-sync), not to this PR's commits. PR commits touch no kernel/, no config surface, no env vars, no wire protocol.
  2. #6011 mechanics. Traced the full population in src/session-id.ts / src/session-resolve.ts / src/server/handle.ts: exact-banner exclusion (reworded banner degrades to pre-SDK serial behavior, never mis-splits a main turn whose text merely mentions the phrase); reminder-strip + advance-past-reminders-only messages with raw-text floor; new anthropicLaterUserFrag (skips the first material user message, joins up to 4 later ones, each reminder-stripped and capped at 512 chars, \u0001-separated); resolver collision-widening rung adding a fourth segment <base>:<fp16(wide)>, guarded by extendsOccupant/keepsTail so occupant growth, equal retries, and fragment-verified tail continuations never rename. Ordering verified: the #5719 msgid rescue fires BEFORE heuristic widening — identity evidence outranks the discriminator. Final call site checked argument-by-argument: the wide discriminator is the 10th, trailing, source-compatible parameter; only the claude-anthropic lane passes it.
  3. Steady-state trace. Healthy runs (distinct first-user fragments) never contest a base key → byte-identical pre-change keys. Colliding runs each widen onto distinct keys. Equal-retry stable. Occupant growth extends its own skeleton (no rename). Stale shorter replays take the widened key until the client catches up (self-heals). Native compaction re-keys once onto the fresh base fragment — pre-existing #5095 behavior class, pinned by test.
  4. Tests. Six new rows across the two suites: positive field-shape scenario (first arrival claims the plain three-segment key, colliding run widens, retry stable, occupant growth causes no rename, widened run stays isolated as its window grows, compaction one-time re-key), a NEGATIVE control (distinct first-user frags → exact pre-change bytes, no fourth segment ever), and a DEGRADATION control (wide arg absent AND empty → today's collision reproduced byte-for-byte). Both directions asserted per gate discipline #3617; assertions have teeth (the collision row fails pre-fix); counts match the body's claim (26).
  5. Disclosure. The PR body carries a complete old→new behavior section including the #6011 stability properties and honest residuals: (a) if a run's first four later user messages are ALL shared, the widened fingerprints stay equal and the collision persists (far narrower than before); (b) compaction one-time re-key is a pre-existing class; (c) stale-replay self-heal is strictly better than the old clobber-and-rewind.
  6. CI. 30/30 green at this exact head via the mirror cache (the non-success rows are by-design gated e2e lanes, skipped).

Regression inventory (existing behaviors on touched paths)

Interactive CLI main lane — byte-unchanged · -p one-shot — unchanged · legacy subagent shapes (agent-id / parent headers) — unchanged · headerless traffic outside the persona-order gate — untouched (gate itself unchanged) · D1-B/D1-C fork-key widening semantics — unchanged · #5719 msgid rescue ladder — ordering preserved · nudge/kernel/wire — untouched. No unintended regression found.

Small finding fixed on spot

已顺手修:tests/claude-subagent-split.test.ts 文件尾多余空行(EOF 后多一个空行)+ commit 4c1559c(whitespace-only,零语义影响)

八问

  1. 是什么问题:Claude Agent SDK 的 subagent 轮次被误判为主会话而并入父会话车道;且同类型并发 subagent 首条用户消息逐字节相同(共享 CLAUDE.md 样板)时,全部撞进同一条压缩车道互相踩踏骨架(#6011 实测缓存命中 68.7% vs 主会话 95.0%)。
  2. 什么原因导致的:主会话分类器匹配了每个 SDK 轮次都带、不含任何分类信号的 harness 横幅;D1-B 判别子直接取首条用户消息前 1024 字符——前置共享 <system-reminder> 吃满整个上限,首消息整体是样板时更是没有任何区分度,键函数对并发运行不具单射性。
  3. 影响范围与严重程度:CC 2.1.308+ / Agent SDK 用户的 subagent 流量;属 p1 级缓存泄露面——三个并发 subagent 会话被压成一个会话,~31% 输入量贡献 ~74% 非缓存成本;交互式 CLI / -p / 旧版形状不受影响。
  4. 怎么修复的:harness 横幅按精确前缀排除(改写即安全退化)+ SDK 主会话标记入 MAIN_SYSTEM_PREFIXES;reminder 剥离后再截断、跳过纯 reminder 消息(floor 兜底);新增宽判别子(跳过首条实质消息后取至多 4 条后续用户消息、各剥离后限 512 字符),仅在解析器碰撞加宽档消费——被占用的基础键加宽出第四段,冲突方各归其键、占用者骨架不动;参数为源码兼容的尾参,唯一调用点传入。
  5. 是否有回归问题:无——全人群推演(交互式 CLI / -p / SDK 主 / SDK sub / 旧版形状 / 仅 parent header / 无 header)除有意修复外全部字节不变;健康运行永不加宽(负向对照钉死);宽判别子缺失或为空时逐字节复现改前行为(退化对照钉死);#5719 msgid 救援先于启发式加宽的次序保持;未触碰 kernel/配置/env/线协议。
  6. 是否破坏缓存:本修复本身恢复缓存正确性(此前碰撞车道正是 miss 源头);受影响的派生人设车道升级时一次性改名(冷启动、无数据丢失);加宽后的键在运行生命周期内字节稳定(入站历史追加式增长 + 早期共享消息尾部追加越过 512 上限即冻结)。
  7. 是否改了设计方向:否——在既有 D1-B/D1-C 人设车道机制上增加一段可选判别子;身份阶梯语义不变(msgid > 顺序 > hash,加宽只是 fork 分支末档行为)。
  8. 是否引入了新的配置:否——无新 env、config 字段或灰度开关。

Verdict: APPROVE — clean at final head 4c1559cb3; CI green; behavior changes fully disclosed. Merge itself stays human (§7.4: session-identity logic).

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

Round-2 review complete (new head since my round-1 approval). The PR gained the #6011 collision-widening fix (194bdbeee) + tests (bd0527cd8) plus two master merges — I re-verified end-to-end at git level: both merges proven pure (result vs master tip = exactly the PR's 5 files), full-population trace of the widening rung (healthy runs never widen, colliding runs isolate, retries stable, occupant growth no-rename, stale replay self-heals), msgid-rescue-before-heuristic ordering preserved, call-site arg order checked, 6 new test rows pin positive/negative/degradation per gate discipline #3617, body's old→new disclosure incl. residuals is complete and accurate, no kernel/ touch by PR commits.

已顺手修:tests/claude-subagent-split.test.ts 文件尾多余空行(EOF 后多一个空行)+ commit 4c1559c(whitespace-only,已推到 PR 分支;PR head 现为 4c1559c)

CI 30/30 green at final head 4c1559cb3 (mirror cache). Fresh APPROVE posted: pull/5726#pullrequestreview-5825882030 (round-1 approval was auto-staled by the new commits). No kernel/ or kernel-change declaration → no decision escalation needed. Merge awaits you (§7.4).

@ranxianglei

Copy link
Copy Markdown
Owner

ework 这个应该可以通过sessionid+msgid区分?检查最新master

@ranxianglei

Copy link
Copy Markdown
Owner

参考这个方案 #6011 (comment)

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

检查了最新 master(444630170,比本 PR 的 base 63a40600e 新 117 个提交)——先说窗口结论:这期间 lane-key 派生、msgid 救援、身份采集路径零改动(唯一沾边的 kernel/src/wire/anthropic.ts +12 行是无关的 system-position heal #4570,src/session.ts 是 #5912 配置 overlay)。所以以下判断对当前 master 成立:

当前状态下,sessionid+msgid 区分不了 #6011 那种并发同类 subagent 撞车道,三个结构性原因:

  1. 通道默认关 + 仅回环。master 上确有该设施(Investigate and integrate a stable "session + message ID" identity channel on a per-client basis. Current status: only f | 逐客户端调查并接入稳定"会话+消息ID"身份信道:现状仅 dsh/omp/pi/opencode 四车道在跑,其余(codebuddy/hermes/claude/codex/zcode…)按清单逐个研究 #5825/[PR] release review #5826):src/identity-claude.ts 从本机 transcript JSONL(~/.claude/projects/<cwd>/<sessionId>.jsonl)收割每行 UUID,对齐出站尾巴取当轮 msgid。但 src/identity-harvest.ts:189-193 双门默认关(env BILI_IDENTITY_HARVEST 或灰度键 identityChannelHarvest)且 isLoopbackAddress 信任边界。Claude Code sub-agents are getting a lot of cache misses, but the main session is fine. | Claudecode 子代理大量 miss 缓存,主会话没事 #6011 现场日志(v0.1.213,3 天)已实证:三个并发运行到达时全部零 msgid 载体。
  2. claude 适配器的可见行投影显式跳过 sidechain 行。src/identity-claude.ts claudeVisibleRows:if (o.isSidechain === true) continue;——subagent 流量恰是 sidechain 部分;对齐失败按契约整轮退化 null。还要求 bili 与 CC 同机读本地文件 + x-claude-code-session-id 连接头 + 恰好一个无歧义的 jsonl。
  3. 就算 msgid 全覆盖,resolver 的 msgid 档是合并方向而非分裂方向。src/session-resolve.ts:369 tryMsgIdRescue:入站 id 与 raw key 下存储 id overlap ≥1 ⇒ 判定同一会话、re-anchor([resolveSessionOrder] Full compaction and persona tag drift occurring in the same turn → inevitably forks to |sub: side | [resolveSessionOrder] Full compaction and persona tag drift occurring in the same turn → inevitably forks to |sub: side | [resolve… #5719);overlap=0 时按「degrade over half-trust」不作为任何证据——不存在「id 不相交 ⇒ 拆到不同车道」的档。且 lane-key 派生(D1-B/D1-C fork key)完全不消费 msgid(resolveSessionOrder 签名里 msgIds/readStoredMsgIds 是末两位参数,只被 tryMsgIdRescue 用)。两个共享同一 session id 的并发运行,无论各自 id 流多丰富,都会落在同一个基础车道键上——id 能证明「和已记录的某会话是同一个」,但不能回答「这是哪一个运行」。

这正是本 PR 走内容宽判别子路线的原因:它是这种线形流量里线上字节自身携带的唯一区分信号,且缺失/为空时逐字节退化为改前行为(退化对照测试钉死)。

顺带两点:① 若未来 CC/SDK 版本在 wire 上盖了 per-run session id 或逐消息 id,碰撞本身消失、加宽档永不触发(负向对照已钉死),本 PR 与该方向不冲突、不挡路;② 如果你想把「disjoint msgids ⇒ 分裂」立成身份阶梯的新语义,那是 KDD #11 的设计变更(另立工作项讨论),不是这个 PR 的范围。

PR 状态不变:APPROVED @ 4c1559cb3,CI 30/30 绿,等你合并。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

对着最新 master(444630170)把这条方案的关键论断逐条核实过了,先认账:它对我上一轮「拿不到 msgid」的纠正是对的——我按 KDD #18 的 harvest 适配器(有门、仅回环)框定了可用性,漏了 raw-wire toolCallIds 这条无门、无回环要求、纯解析请求体的通道。核实结果:

一、方案里我独立验证成立的部分

  • collectRequestIds(src/request-membership.ts:28):envelope biliMsgIds 优先,否则取线上回发的 m.toolCallId——注释原文即「the only ids the raw protocol wires carry」。CC 子代理流量第 2 轮起天然携带。
  • anthropic 车道今天每请求已在提取:src/server/prepare-anthropic.ts:665 probeRequestMembership(session, collectRequestIds(incomingMsgIds, originalMessages), …);当前唯一消费者是 Bypass requests overwrite the main session's usage anchor, causing long sessions to permanently stop compressing. | 旁路请求覆盖主会话 usage 锚点,导致长会话永久停止压缩 #4805 membership settle gate,evidence-only,不进车道键决策。
  • fork 出口车道键(src/session-resolve.ts ~:502):disc !== "" ? ${rawId}|sub:${fp16(tag)}:${fp16(disc)} : ${rawId}|sub:${fp16(tag)}——id 从不参与新车道创建;tryMsgIdRescue 只有合并方向(重叠⇒回锚;零重叠⇒null)。
    → 同意方案的核心判断:瓶颈在 resolver 消费规则,不在取数。

二、我的独立补充(方案没展开、落地前必须钉死的点)

  1. 第 1 轮撞键对任何服务端方案都信息论上不可避免:三条并行 run 的首个请求逐字节相同(共享样板前导、尚无 tool call),两个字节相同的请求不携带任何区分信号。A / C-wire / C-jsonl 共享同一残留:第 1 轮各吃一次 clobbered pass,第 2 轮起分离。方案里 A 选项「第 1 轮即修复」严格说只对 field log 那种到达时已带 ≥4 条后续 user 消息的既有 run 成立;真正新鲜的并发派发,三方案同窗口。
  2. C-wire 有两个设计缺口,不定死会帮倒忙:
    • 稳定性锚:规范化 id 集随历史重发单调增长(append-only、每轮全量重发)——直接 hash 全集 ⇒ 车道键每轮变 ⇒ 缓存立刻崩。必须锚到不变量,例如「入站集中最早一个不在 occupant/raw 存储集里的 id」(各 run 首个自铸 toolu_*,run 生命周期内不变)。方案「键由规范化 id 集派生」把这留白了。
    • 重叠语义:共享父前缀的 tool id 三条 run 相同——集合并非两两不相交,不相交的只是各自的尾部段。「入站 id 非空且与存储无重叠 ⇒ 拆」需明确跟哪个存储集比(raw?occupant 车道?)、部分重叠怎么判(fork 继承重试会共享一部分 id——方案八问第 5 条自己点了这个风险)。粗版「与 raw 存储零重叠」在 field shape 下可能根本不触发。
    • 另按方案自己的建议,C-wire 还要在 ingest 把这些 id 钉进统一存储(否则 rescue/membership 后续看不见)——这是身份空间 + 存储写路径变更(§7.4 human-gated),无论如何都是独立 PR。
  3. A 与 C-wire 的覆盖不对称(对着 PR head 4c1559c 代码核实):anthropicLaterUserFrag 只读 user 消息的顶层 type:"text" part,纯 tool_result 消息被跳过(src/session-id.ts:312-329,有意为之)。所以判别材料埋在 tool_result 块里(工具输出)时,A 要等到出现文本 user 消息才分离;C-wire 的 id 信号与内容类型无关,工具密集型 run 分离得更早更可靠。反过来纯文本从不调工具的 run:A 有效,C-wire 退化现状。两者互补而非互斥——按 KDD feat: self-update (auto + manual) #11 msgid>顺序>hash 阶梯,C-wire 的 id 档排在 A 的内容宽档之前(id 可用且非重叠 ⇒ id 键;否则落 A 的 widening 档;都没有 ⇒ 基础键),可以叠加。

三、建议(明确,不甩选择题)

八问(决策向)

  1. 是什么问题:同一会话下并行 ≥2 个同类型 CC SDK 子代理、首条 user 消息逐字节相同时撞进同一条压缩车道,子车道缓存命中大跌(68.7% vs 主车道 95.0%)。
  2. 什么原因导致的:D1-C hook token 缺位 → 落到 D1-B discriminator=首条 user 片段 → 跨 run 字节相同 → fp16(disc) 相同 → 同键;msgid 从未接入车道键决策。
  3. 影响范围与严重程度(分选项):受影响面相同(未装 hook 的同会话并行 Task 用户),成本类严重、能用但贵,维持 p1(缓存命中崩坏类)。A:field shape 从首个分歧轮起修复;C-wire:工具型 run 第 2 轮起、纯文本 run 不受影响;C-jsonl:理论上第 1 轮即可,但默认关 + 仅回环,rollout 扩大前实际影响有限。
  4. 怎么修复的:A=有界推进扫描 discriminator(纯服务端,已在 PR);C-wire=fork 出口加 id 消费档(最早 run-specific id 锚定派生)+ ingest 钉存统一存储;C-jsonl=sidechain 线程投影对齐 + 同一消费规则。
  5. 回归风险(分选项):A=discriminator 语义漂移(reminder 前缀既有车道一次性迁移,golden 钉住 + 健康 run 字节不变负控已在 PR);C-wire=resolver 新增 id 消费点,部分重叠误判(fork 继承重试共享部分 id)须先定义比较集与裁决;稳定性锚做错=每轮换键、缓存比现状更差;C-jsonl=面最大,KDD fix: suppress duplicate auto-update notices within one process #17 parity 先行 + §7.4 human-gated。
  6. 是否破坏缓存:修复目标即恢复命中;三者都不使已有缓存失效(车道键推导是本地簿记)。A 的一次性 re-key=新车道冷启动,无数据丢失。
  7. 是否改了设计方向:A 无方向变化(内容 discriminator 族内扩展);C-wire/C-jsonl 沿 KDD feat: self-update (auto + manual) #11/fix: suppress duplicate auto-update notices within one process #17/release v0.1.6 #18 推进「msgid 参与车道创建」,属方向强化非转向。
  8. 是否引入新配置:三方案均无新 env/config(harvest 的 rollout 门为既有)。

结论:建议 A 现在合(#5726 就绪)、C-wire 设计后开 follow-up、C-jsonl 留设计项——等你拍板。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

收口确认:完整评估已在上条发出(对 #6011 方案评论的逐条核实 + 三点独立补充 + 分选项八问)。一句话结论:建议先合 #5726(A)——已就绪(APPROVED @ 4c1559cb3、CI 30/30 绿、零客户端依赖);C-wire 待稳定性锚 + 重叠语义定稿后开 follow-up PR(§7.4 身份逻辑人工评审);C-jsonl 维持设计项。若你想 C-wire 先行,#5726 保持 open 等拍板即可——A 无论如何都是 C-wire 在「id 缺席」时的降级底。合并由你执行。

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code SDK subagents match MAIN_SYSTEM_PREFIXES and long shared <system-reminder> blocks collide in anthropicFirstUserFrag

2 participants