Repository navigation
[PR] fix(zcode): normalize sess_ prefix + ring-record non-plugin tool calls (#6433) - #6472
ranxianglei wants to merge 12 commits into
Conversation
…roxy session (#6433) zcode's bootstrap-hook injects CLAUDE_CODE_SESSION_ID with a sess_ prefix (sess_<uuid>), but the proxy's plugin routing keys sessions by the bare uuid (the model request header carries the bare form). Neither side stripped the prefix, so the shim's default binding always 404'd with 'unknown plugin conversation'. Fix: strip the sess_ prefix at all three id-extraction points: - src/mcp.ts: CONVERSATION_FROM_ENV (shim env binding) - src/plugin.ts: handlePluginTool body conversationId (defensive, for older shims) - src/session-id.ts: conversationHeaderSource (model request header, for robustness) The shared stripSessPrefix helper lives in src/session-id.ts. No other client uses this prefix (grep-verified), so a global strip is safe.
…e lane (#6433) The unbound zcode subagent shim (no CLAUDE_CODE_SESSION_ID) routes via the witness ring, but the ring was only fed by the plugin-mode response pipe (settleWitnesses), which early-returns when no session object is passed. The non-plugin lane deliberately passes undefined to keep usage accounting off, so a subagent's own outbound tool calls were never ring-recorded and the witness route always missed. Add an optional witnessSessionId parameter to pipePluginChatWithStrip and pipePluginResponsesWithStrip; settleWitnesses now records under that id even when the full session is absent, so usage accounting stays off while the witness ring is still fed. The non-plugin SSE branch in relay.ts passes p.session?.id as the witness id.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10202-pr.6472.a50a479This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6472.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: qwen/qwen3.8-27b) PR #6472 review. Duplicate screening: Not a duplicate. Two distinct zcode defects in the same root area (zcode shim ↔ proxy identity/routing seam). Related to #4661/PR#4691 (zcode doesn't inject session id, not merged) — that's the OTHER HALF of the same root area (Problem A here is "injected but prefixed, resolution fails"; #4661 is "not injected at all"). Different mechanisms, same root area — correctly kept in one PR. Reviewed the full 5-file diff at head 8-question review (8问):
结论: 方向正确。Fix 1 完整且安全(3 个提取点全覆盖、两侧一致、无碰撞)。Fix 2 对 SSE(流式)case 正确且是正确性改进(消除误路由 bug)。两个 GAP(非流式 JSON 路径未喂环 + 非插件车道 建议(follow-up,不阻塞):
|
[bot] 🏷 (ai: qwen/qwen3.8-27b) CI update: green — 30/30 checks complete, 14 success + 16 skipped, 0 failed (head Final verdict: 可合。Fix 1( |
Resolve the signature conflict: both this PR (#6433, witnessSessionId) and master (#5951, hostOwnsTruncationRecovery) added a new last param to pipePluginChatWithStrip / pipePluginResponsesWithStrip. Keep hostOwnsTruncationRecovery in its original position and append witnessSessionId after it; the 3 non-plugin call sites in relay.ts pass hostOwnsTruncationRecovery first, then the witness id.
…writer + notice-registry)
[bot] (ai: vllm-qwen/qwen3.8-27b) CI 工程师接管完成:冲突已解、继承红项已收敛、已推送,CI 正在新 head 上跑。 做了什么
八问
待办:CI 正在新 head 判定:冲突与红项已一次处理完,代码侧就绪,等 CI 绿即可合。 |
…ON lane (#6433) The witnessSessionId seam added by this PR covered only the two SSE pipes (pipePluginChatWithStrip / pipePluginResponsesWithStrip). The non-streaming non-plugin lane (relay.ts pipePluginJson) still passed no session, so a non-streaming subagent's outbound tool calls were never ring-recorded and the unbound shim's witness route kept missing them. Mirror the SSE pattern: pipePluginJson takes an optional trailing witnessSessionId and records under witnessSessionId ?? session?.id; the relay JSON branch passes prepared.session?.id. Plugin-lane callers are unaffected (session already passed, witnessSessionId omitted). Adds the missing non-plugin witnessSessionId regression tests (SSE + JSON).
(ai: vllm-qwen/qwen3.8-27b) PR #6472 审核(head 查重:不重复。两个独立的 zcode 缺陷,同一根因区域(zcode shim ↔ 代理身份/路由缝)。与 #4661/PR#4691 相关但机制不同——那是「根本没注入 session id」,本 PR 是「注入了但带 独立审核:未照抄前几轮结论。自己重读了 5 文件 diff、追踪了 witness ring 的完整调用图( 8问:
已顺手修:非流式 JSON 车道的见证环喂给缺口(原 PR 只扩展了 SSE 管, ci-fixes 说明:diff 里 CI:我推了新 head 判定:方向正确,两个缺陷都修到根因(前缀不对称 + 见证环喂给路径不完整);我补齐 JSON 车道缺口后 SSE+JSON 全覆盖,测试钉住核心路径。可合(等 CI 绿)。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) PR #6472 审核完成,判定:可合(等 CI 绿)。 做了什么:
状态:CI 在新 head |
# Conflicts: # tests/e2e/e2e-native-dsh-persona.test.ts # tests/e2e/e2e-native-dsh.test.ts # tests/e2e/e2e-native-opencode.test.ts # tests/e2e/e2e-native-pi.test.ts # tests/e2e/e2e-pi-codex-ws.test.ts # tests/e2e/e2e-subagent-sessions.test.ts # tests/notice-registry.test.ts # tests/plugin-fork.test.ts
On Windows, new URL(import.meta.url).pathname yields /D:/a/... (leading slash before the drive), so path.resolve prepends the current drive and the module-level readFileSync opens D:\D:\a\...\package.json and crashes the whole test file at import time. import.meta.dirname is the cross-platform form already used by every sibling e2e test.
# Conflicts: # tests/e2e/e2e-selfupdate-cli.test.ts
# Conflicts: # src/plugin.ts
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Conflict resolved + red item handled Duplicate screening: not a duplicate — this PR is the zcode What I did
CI status: 26 success + 1 fail + 1 skipped. The only red = Red-item verdict
八问 (8-question checklist)
Verdict: conflict resolved, PR code correct (typecheck + tests pass), CI red is a windows 22,2 timing flake (not introduced by this PR), fresh-runner re-run triggered — will follow up with the result. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-run result: CI is now fully green The fresh-runner re-run of the failed Final state
Verdict: the PR is ready for human review and merge — no conflict, CI green, code correct. The only remaining gate is the required review approval (human-only). |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 新 head 这次 head 变了什么:相对我上轮审核的 独立复核(未照抄上轮):重新拉了新 head 相对新 master(
merge 有没有破坏 PR 逻辑:没有。merge 是纯 master/ci-fixes 推进,PR 的 6 个核心文件内容与我上轮审核逐字一致( 本地验证(新 head):typecheck 干净(exit 0)+ 定向测试全绿——proxy-session-id 23/23、tool-witness-pipes 9/9(含我上轮补的 2 条)、tool-ring 26/26。 8问:
判定:方向正确,两个缺陷都修到根因;我上轮补齐的 JSON 车道缺口 + 回归测试已在新 head 内;merge 干净、无新 PR 代码、CI 全绿、本地定向全绿。可合。 |
[ework] CI fix verified green ✓ |
What
Two zcode defects in one PR (same thread, same root area — the zcode shim ↔ proxy identity/routing seam):
sess_prefix never stripped — zcode bootstrap-hook injectsCLAUDE_CODE_SESSION_ID=sess_<uuid>; the proxy keys sessions by bare uuid. Neither side stripped the prefix, so the shim's default binding always 404'd withunknown plugin conversation.CLAUDE_CODE_SESSION_ID) routes via the witness ring, but the ring was only fed by the plugin-mode response pipe (settleWitnesses), which early-returns when no session object is passed. The non-plugin lane deliberately passesundefinedto keep usage accounting off, so a subagent's own outbound tool calls were never ring-recorded and the witness route always missed.How
Fix 1 (
stripSessPrefix): new helper insrc/session-id.tsthat trims and strips a leadingsess_. Applied at all 3 id-extraction points:src/mcp.tsCONVERSATION_FROM_ENV(shim-side env read)src/plugin.tshandlePluginToolbodyconversationId(proxy-side body parse)src/session-id.tsconversationHeaderSourceheader walk (proxy-side header parse)Fix 2 (
witnessSessionId): optional last param onpipePluginChatWithStripandpipePluginResponsesWithStrip;settleWitnessesnow records underwitnessSessionId ?? session?.id, so the witness ring is fed on the non-plugin lane while usage accounting stays off.relay.tsnon-plugin SSE branch passesp.session?.id.Tests
tests/proxy-session-id.test.ts: 2 new cases (stripSessPrefix unit + header normalization), 23/23 pass.tests/tool-ring.test.ts: 24/24 pass (no regression).tests/tool-witness-pipes.test.ts: 7/7 pass (no regression).Related
Closes #6433