Skip to content

fix: recognize the dsh title sidecar on the anthropic wire — no more |sub: ghost rows (#3149) - #3150

Closed
deshark42 wants to merge 2 commits into
ranxianglei:masterfrom
deshark42:2026-10-14_dsh-title-sidecar-anthropic
Closed

deshark42 wants to merge 2 commits into
ranxianglei:masterfrom
deshark42:2026-10-14_dsh-title-sidecar-anthropic

Conversation

@deshark42

Copy link
Copy Markdown

Fixes #3149

问题

dsh 原生 lane 走 anthropic 线:标题生成提示词在顶层 `system` 字段,`messages` 里只有人类消息 blob。`isDshTitleRequest` 原本只扫 `messages[role=system]`(#2503/#2554 覆盖的是 OpenAI 形态),于是标题旁路请求被当成主回合:

  • 标题先到 → 占住裸 id,真实会话被 fork 到 `|sub:` 幽灵;
  • 标题后到 → 自己落到 `|sub:<fp16(标题提示词)>`。

两条路都会走管线落盘,`walkSessionFiles`(src/web/sessions-data.ts)各列一行 ⇒ 同一个 dsh 会话在 Web UI 显示两行(现场 28 条记录里 11 条是 487 字符的标题提示词幽灵)。标题先到时还有 #2156 的伤害形态:宿主盖章的 `compress`/`acp_status` 按裸 id 路由到标题幽灵的空账本。

修复

`src/server/side-request.ts`:抽出 `systemCarrierTexts()`,对全部系统载体做前缀判定后再决定是否旁路——

  • anthropic:顶层 `system`(string 或 `[{type:"text",text}]` 数组)
  • responses:顶层 `instructions`
  • google:`systemInstruction.parts`
  • 以及 `messages` / `input` 里 role 为 `system` / `developer` 的条目(覆盖 OpenAI 旧形态)

前缀常量与 no-tools 否决不变;调用点仍是 handle.ts 的 `pluginAgentHeader === "dsh"` 门控,其它宿主不受影响。

证据 / 测试

  • `tests/dsh-title-sidecar-handle.test.ts`:新增 anthropic 形态的真实代理路径用例(标题先到 → 无 `|sub:` 行、主回合后 `stats.requests` 仍为 1、请求按原样转发、usage 基线不动)。
  • `tests/dsh-title-side-lane.test.ts`:顶层 system 字符串/块数组、responses `instructions`、google `systemInstruction`、`developer` 载体的正例 + 无标题/带 tools 的反例。
  • 本地(rebase 到 cc58345):`npm run typecheck` 干净;8 个相关套件 73/73 绿(含 dsh-persona-fingerprint、side-lane-truth-table、side-lane-invariants、side-request-isolation、fix-1075-side-request、fork-side-request-lane)。

与 #2944 v2 的关系

这不是身份阶梯的问题:#2944 的顺序优先解析器(`src/session-resolve.ts`)里,携带 persona tag 的浅 blob 依然会 claim 裸 key(:173-177),tag 变化且历史不延续时依然 fork 到 `|sub:<fp16(tag)>`(:238-240)。本修复的作用是把标题请求挡在解析器之前(`!sideRequestLike` 门),因此与 #2944 正交、在 master 上仍必要。

影响面 / 纪律

…ei#3149)

dsh's native lane rides the anthropic wire, where the title system prompt
sits in the TOP-LEVEL system field while messages[] holds only the user
blob. isDshTitleRequest scanned messages[role=system] only (ranxianglei#2503 covered
the OpenAI carrier), so the sidecar looked like a main turn: it claimed
the raw session anchor and the real conversation forked onto a persisted
|sub:<fp> ghost — one dsh session listed twice in the Web UI.

Scan every system carrier (anthropic system string/text-block array,
responses instructions, google systemInstruction.parts, and
system/developer entries inside messages/input) before the prefix match.
The no-tools veto and the caller's x-bili-plugin=dsh gate are unchanged.
@deshark42
deshark42 force-pushed the 2026-10-14_dsh-title-sidecar-anthropic branch from dc319a0 to a73169c Compare October 14, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] dsh 原生(anthropic)的标题请求未被 isDshTitleRequest 识别,同一会话在 Web UI 拆成两行

1 participant