Skip to content

[PR] fix(#6303): persona extractor reads the developer-role system carrier - #6485

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-13_persona-developer-carrier
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-13_persona-developer-carrier

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #6303

What

openaiSystemTextForPersona (src/session-id.ts) read only role: "system", but the wire codec openaiToCore (kernel/src/wire/openai.ts) hoists system or developer. dsh's pi-ai lane emits the system prompt as role: "developer" (string content) whenever the model declares reasoning and the upstream supports the developer role (openai-completions.js instructionRole). With the carrier mismatch, both the main agent lane and the auto-reviewer lane got personaSystemText === "", the dsh persona gate (src/server/handle.ts:1410) stayed false, and both silently rode the verbatim raw key.

The reviewer's divergent all-user history then clobbered the main lane's fold state (30 blocks coverage-lost on every lane switch) and, after a client abort mid-compression, compress resolved against the side lane and died on gate:cannot-anchor — refs marked DEAD, session left with 0 active blocks (#6303).

Fix

Make the persona extractor accept the same carrier as openaiToCore — role: "developer" in addition to role: "system" — so the gate fires and the reviewer forks onto its own |sub:<fp> lane instead of clobbering the main lane. Scoped to the dsh lane (the gate already requires x-bili-plugin: dsh); non-dsh clients are untouched.

Direction agreed in-thread with the reporter (#6303 floor 13: "make openaiSystemTextForPersona accept developer (matching openaiToCore)"; both lanes confirmed developer + string content).

Tests

  • Unit: openaiSystemTextForPersona reads developer-role string content + text parts, empty content contributes nothing, no system/developer still yields empty (non-anchoring).
  • e2e regression: dsh openai lane, BOTH lanes developer-role string content, same conversation id — main lane (tools + assistant turns) keeps the raw key; the no-tools reviewer lane (all-user, different system) forks to |sub:<fp> and does NOT clobber the main refs. Verified the e2e test FAILS on the pre-fix code (reviewer does not fork) and passes post-fix.

Review note

This is identity/session-binding logic — human-gated merge per repo policy (§7.4), no auto-merge.

Part of the dsh-lane root-cause aggregation #6446 (member #6303).

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-13_persona-developer-carrier (e04ccf3)

Latest build — install this exact version

npm install -g billion-context@0.0.9543-pr.6485.1cc0303

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

Recent builds (commit → version)

commit version build
e04ccf3 billion-context@0.0.9543-pr.6485.1cc0303 build
d26adca billion-context@0.0.9458-pr.6485.162a226 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(#6303): persona extractor reads the developer-role system carrier [PR] fix(#6303): persona extractor reads the developer-role system carrier Nov 13, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

Review of PR #6485 — persona extractor reads the developer-role system carrier

Verdict: LGTM — correct root-cause fix, well-scoped, genuine regression tests. Ready for human merge after rebase (identity/session-binding logic → human-gated per §7.4, no auto-merge).

What I verified (independently, not from the PR description):

  • Root cause confirmed. dsh's pi-ai lane emits the system prompt as role: "developer" (string content) when the model declares reasoning + upstream supports the developer role (openai-completions.js instructionRole). The wire codec openaiToCore (kernel/src/wire/openai.ts:84-111) hoists BOTH system and developer, but openaiSystemTextForPersona only read role: "system" → personaSystemText === "" → the dsh persona gate (src/server/handle.ts:1410) stayed false → both main + reviewer lanes rode the verbatim raw key → reviewer's divergent all-user history clobbered main-lane fold state (dsh plugin: second no-tools request lane in the same session invalidates all fold blocks; compress then resolves against that lane and fails with cannot-anchor #6303).
  • Root-cause fix, not a symptom mask. It makes the persona extractor accept the SAME carrier as openaiToCore (system OR developer). The litmus test holds: if the same carrier mismatch surfaced in a different shape tomorrow, this fix still holds.
  • Correctly scoped. openaiSystemTextForPersona is called only for the openai protocol (handle.ts:1247); its output is consumed only in the openai-lane gate (handle.ts:1410-1422), which requires dshPersona. Non-dsh clients and the anthropic/google/responses lanes (different carriers: top-level system / systemInstruction / instructions) are untouched.
  • No regression on the main lane. Pre-fix the main lane rode the verbatim raw key; post-fix it goes through personaConversationOrder and resolves to the raw key (anchor, first system) — the SAME as established dsh system-role main-lane behavior. The reviewer lane (different system) now forks to |sub:<fp> — the fix.
  • sideRequestLike does not block the fix. The real dsh plugin: second no-tools request lane in the same session invalidates all fold blocks; compress then resolves against that lane and fails with cannot-anchor #6303 side request (~250 all-user msgs) and the e2e reviewer (4 user msgs) both have sideRequestLike = false — none of the side-request clauses match a multi-user-message lane (isDshAutoReviewRequest / isDshSingleShotSidecar require exactly 1 user msg). So the gate fires post-fix for the real incident.
  • Tests are genuine (have teeth). Unit: developer-role string content + text parts, empty content contributes nothing, no sys/dev yields empty. E2e: main lane (developer system + tools + assistant turns) keeps the raw key; no-tools reviewer lane (different developer system, 4 all-user msgs, same conversation id) forks to |sub:<fp> and does NOT clobber the main refs. I verified both FAIL on the pre-fix code (reverted src/session-id.ts to base, kept the test) and PASS post-fix. The test's forkKey helper exactly matches the kernel's hashId (sha256(...).slice(0,16), kernel/src/wire/util.ts:7) — faithful reproduction.

Notes:

  1. Stale base (rebase before merge). The PR is behind master (base 33104b1f95, master at fcc2e84848). The PR's two files (src/session-id.ts, tests/dsh-persona-fingerprint.test.ts) are UNTOUCHED on master since the base → the rebase would be clean. The handle.ts changes on master (BILI_PLUGIN_BYPASS x-bili-plugin-bypass: 1 Allow forced specification | x-bili-plugin-bypass: 1 允许强制指定 #6220, codex headroom [PR] fix: do not reserve output headroom twice on a codex live-table window #6165) do not touch the persona gate (line ~1410). Suggest rebasing onto current master before merging.
  2. Related observation (out of scope for this PR). src/generation-boundary.ts:106 skips only role === "system" (not developer) when scanning for stale mNNNNN REF citations. A dsh role: "developer" system prompt would be scanned — a potential false stale-REF if it contains mNNNNN strings. Different function/purpose (REF-citation scanning, not persona fingerprinting); not part of this PR's mechanism. Flagging for awareness.
  3. CI is in progress (10 success, 12 skipped, 8 in_progress, 0 failures so far). The targeted suite (tests/dsh-persona-fingerprint.test.ts) passes locally 13/13.

八问

  1. 是什么问题:persona 提取器 openaiSystemTextForPersona 只读 role: "system",但 dsh pi-ai 车道在模型声明 reasoning 且上游支持 developer 角色时,把 system prompt 发成 role: "developer"。载体不一致 → personaSystemText === "" → dsh persona 门(handle.ts:1410)保持 false → 主车道与 reviewer 车道都走 verbatim raw key → reviewer 的分叉全 user 历史覆盖主车道 fold state(dsh plugin: second no-tools request lane in the same session invalidates all fold blocks; compress then resolves against that lane and fails with cannot-anchor #6303:30 块 coverage-lost,客户端 abort 后 compress 死在 gate:cannot-anchor,refs DEAD,0 个活跃块)。
  2. 什么原因导致的:载体失配——wire codec openaiToCore(kernel/src/wire/openai.ts:84-111)同时提升 system 与 developer,但 persona 提取器只读 system。persona 提取器与 wire codec 对 system 载体的定义不一致,是根因。
  3. 影响范围与严重程度:仅 dsh openai 车道(门要求 x-bili-plugin: dsh + protocol openai)。触发条件:模型声明 reasoning 且上游支持 developer 角色。严重程度 p1——session 不可用(fold state 被覆盖、refs DEAD、0 个活跃块)。
  4. 怎么修复的:让 persona 提取器接受与 openaiToCore 相同的载体——role: "developer" 加上 role: "system"。在源头修载体失配,不是症状遮罩。
  5. 是否有回归问题:无。非 dsh 客户端不受影响(门要求 dshPersona);dsh system 角色车道不变;dsh developer 角色主车道仍走 raw key(anchor),与既有 dsh system 角色主车道行为一致;dsh developer 角色 reviewer 车道现在分叉到 |sub:<fp>(即修复本身);跨协议(anthropic/google/responses)不受影响(不同载体)。
  6. 是否破坏缓存:无。修复改变 reviewer 车道的 session key(raw key → |sub:<fp>),这是预期行为(独立车道);主车道 key 不变(raw key);无缓存失效。
  7. 是否改了设计方向:无。让 persona 提取器与既有 wire codec 约定对齐(两者都读 system + developer),无架构/边界/数据流转向。
  8. 是否引入了新的配置:无。无新 config/env/CLI 字段。

收工判定:修复正确、范围清晰、测试有牙,rebase 到当前 master 后可合(人工合,identity 逻辑 human-gated)。

openaiSystemTextForPersona read only role:"system", but openaiToCore
(kernel/src/wire/openai.ts) hoists system OR developer. dsh's pi-ai lane
emits the system prompt as role:"developer" (string content) when the model
declares reasoning + the upstream supports the developer role, so BOTH the
main and the auto-reviewer lanes got personaSystemText==="", the dsh persona
gate (handle.ts:1410) stayed false, and both silently rode the verbatim raw
key. The reviewer's divergent all-user history then clobbered the main lane's
fold state (30 blocks coverage-lost) and, after a client abort mid-compression,
compress resolved against the side lane and died on gate:cannot-anchor (refs
DEAD, 0 active blocks).

Make the extractor accept the same carrier as openaiToCore so the gate fires
and the reviewer forks onto its own |sub:<fp> lane. Scoped to the dsh lane
(the gate already requires x-bili-plugin: dsh); non-dsh clients untouched.
@ranxianglei
ranxianglei force-pushed the 2026-11-13_persona-developer-carrier branch from d26adca to e04ccf3 Compare November 13, 2026 11:29

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

1 participant