Repository navigation
Conversation
On routes whose model reads a later system message as the effective prompt, dsh does not rewrite the first system node when the rendered prompt changes: SystemPromptProjection appends a complete system message after the cached history, and the Messages serializer ships it as a plain-text role:"system" message after the user turn. The newest such message is the prompt in force. ACP folded it like any plain-text message, so one compress range covering it left the model on the stale head prompt until the text changed again. Add a fifth durable identity to the dsh lane classifier, durable/system-prompt (dshSystemPromptPath), under the existing durable/* latest-per-identity default: the newest copy is pinned, superseded copies stay foldable. The criterion is the role (no text marker exists for a prompt): a non-empty plain-text system-role core that is neither bili's own summary carrier nor a structured system. Structured systems keep the kernel's hard pin; the classifier reuses hasUnrecoverableMediaPayload so the two rules cannot overlap and a tool delta arriving after the prompt cannot take its latest slot. The identity is consulted before the twelve marker classifiers. Their role gate only refuses the assistant role, so a system prompt that quoted a carrier marker used to project to that carrier's identity and take the latest slot from the real user-channel instance. Host layer only: no change under kernel/, no config field, no wire or persistence change. Other lanes keep folding plain-text in-history systems. oneShotCarrierPaths (drift accounting) is unchanged.
… limits Follow-up to the durable/system-prompt identity, from review. Tests: - Messages wire end-to-end: assert the role the kept prompt is forwarded with. Once the fold removes the assistant that followed it, the kernel's position heal re-voices a plain system as user, so the text survives and the system role does not. Pinned as a known limit; a kernel that relocates instead of demoting flips the assertion. - Lane wiring: drop the "registry keys are exactly [dsh]" pin (another lane registering a classifier is not this test's business) and assert instead that no other lane projects a plain-text system. - Drift registry: pin that system-role text containing a carrier marker is still accounted by marker there, as before the identity existed. - The chat-completions scenario cites the llm-pi-ai wire test it mirrors. Comments only in src/durable-message-guards.ts: where a developer message carrying text would share the identity (llm-pi-ai splits the text off on chat-completions and responses), and that the drift chain has no system-role step. Devlog: no retroactive unfold for prompts already covered by a block from an earlier build, the token cost of a never-folded copy, and the corrected red count on master (9 of 14).
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A moderate active issue remains in src/durable-message-guards.ts where using msg.text.trim() as a whitespace check can unnecessarily allocate large strings (e.g., ~45K chars) and create avoidable memory churn in a repeatedly-invoked path, so a non-allocating whitespace test is needed.
1 open issue
What changed in this PR
Fix a dsh-lane correctness bug where the latest effective in-history system prompt could be folded into a summary, causing requests to run with a stale head prompt until the prompt text changes again.
Changes:
- Add a new dsh durable identity
durable/system-promptto preserve the newest plain-text in-history system prompt while keeping superseded copies foldable. - Prioritize this identity ahead of marker-based durable carriers to prevent carrier-slot takeover.
- Add regression coverage for classifier behavior, compression geometry, and real folding on both Messages and chat-completions wires, plus update inline docs/devlogs.
| File | Description |
|---|---|
| tests/dsh-system-prompt-durable.test.ts | Adds a new regression test suite validating that the newest in-history system prompt is preserved through classification and real compression for Messages and chat-completions wires. |
| src/durable-message-guards.ts | Introduces dshSystemPromptPath (durable/system-prompt) and wires it early in the dsh classifier so the latest plain-text system prompt is protected from folding. |
| src/config.ts | Updates configuration documentation comments to include the new durable/system-prompt identity alongside existing dsh durable carriers. |
| devlog/2026-11-12_dsh-durable-system-prompt/WORKLOG.md | Documents the investigation, implementation notes, testing performed, and known limitations for the dsh durable system-prompt change. |
| devlog/2026-11-12_dsh-durable-system-prompt/REQ.md | Captures the requirements, acceptance criteria, and explicit non-goals for preserving the latest in-history system prompt in dsh. |
Review effort: Balanced
dshSystemPromptPath used msg.text.trim().length > 0 only to ask whether the text has any non-whitespace character. trim() allocates a copy of the whole prompt (tens of thousands of characters in the reports that motivated the identity), and the classifier is consulted repeatedly during protection and fold checks. /\S/.test(msg.text) answers the same question (same whitespace set as trim) without the copy. No behavior change; the existing negatives (empty and whitespace-only system nodes) cover it. From review on the PR.
|
先不跟批次(#6455)一起合,单独留在这里审。原因: 这是 8 个 PR 里唯一引入新折叠语义的一个——新增第五个 durable 身份 review 下来的具体关注点:
不着急合。owner 会在这个 PR 上继续审,有结论会回复。 |
[bot] 🏷 查重: 不重复。 这是修 #6352 的独立 PR,与 #6193(成本/内核去重)、#4818/#5800(结构化 tool-delta system)、#4172(coreToAnthropic 角色)相关但机制不同——本 PR 只动宿主层 dsh 的 durable 分类,不碰内核、不碰 wire、不做去重。 我独立复现了 bug 并验证了修复,针对你(floor 2)的三点关注逐条给证据。 独立验证(不依赖 PR 作者环境)
关注点 1 — 角色身份 vs head/in-history(跨模块隐式契约)
所以 dsh 车道上 system 角色的 core 消息就是历史内的那种——隐式契约今天成立,且被测试断言钉住(leading system 不进 core)。 你担心的"将来第三种 system 文本消息会被静默钉住"是真实残余风险,但有三道现有防护:① 分类器只在 dsh 车道接线( "prompt 分类器排在 marker 分类器之前会抢真载体的 latest 槽位"——这正是 PR 要修的(master 上含载体标记的 system 提示会被投影成那个载体的身份并抢槽),PR 用测试 "the four durable carriers keep their own latest slot next to the prompt" 钉住了修正后的行为。 关注点 2 — 行为双向
关注点 3 — 按路线收窄 vs 先只加可折一半
代码质量(⑤b 外部提交从严):通过。命名遵循 测试有效性(④):有牙。三层——分类器行(正反双向,#3617);折叠几何(经真实编解码器 + 结构化八问
建议:按现状可合。bug 真实、修复最小且测试充分;Messages wire 上角色降级是内核既有行为且已钉住,内核侧的位置迁移是独立的(kernel-gated)后续,PR 作者已表示可另开 issue(按本线程规则我不自行开,留给你决定)。你 floor 2 保留的两个选项,证据结论是:「按路线收窄」在分类器层不可表达且不需要,「先只加可折一半」等于什么都不加——所以有意义的选择是「按现状合 vs 等内核侧角色迁移先做」,我推荐前者。 |
dshSystemPromptPath excludes an empty node by looking at the core's text. That text is not the host's bytes in two places, and in both an empty system node read as non-empty, took the durable/system-prompt identity and, when it came after the prompt in force, its latest slot: - The Messages codec gives an empty system message the placeholder text "[system]" (the same value seeds the id). An empty string content and a single text block with empty or missing text were therefore not excluded on that wire, and the prompt before such a node was foldable again. - A view rendered with ref tags puts the tag in front of a numbered message's text, so there an empty node read as non-empty on all three wires. The plugin tool endpoint classifies that view for its status and recommendation recompute, with the wrong protection set; the fold itself reads the raw view where it has one. hostSentSystemText asks the verbatim wire sidecar that the Messages, chat-completions and responses codecs attach to an in-history system (rawAnthropicMessage, rawOpenaiMessage, rawResponsesItem) whether the host sent any non-whitespace text; a core without a sidecar is judged on its text, as before. It is not a comparison against the placeholder: a host that really sends those eight characters keeps the identity. The change only narrows what the identity matches. No kernel change. Tests go through the real codecs: the empty Messages shapes, an empty node after the prompt in a fold, and the rendered view on each wire. Three of the sixteen fail on the previous head. Empty in-history system nodes are recorded on the chat-completions wire (tests/issue4778-dsh-goal-subfork.test.ts). The dsh 0.2.2-rc.2 package puts none on the Messages wire, so there this closes the documented exclusion rather than a reported failure.
|
(ai: anthropic/claude-fable-5-2) 补了一个提交( 1. 改了什么
改法:新增模块内的 2. 这种节点哪里会出现
3. 和关注点 1 的关系 和关注点 1 是同一类后果(latest 槽位被抢),成因不同:不是宿主放出了另一种有文字的 system 消息,而是 4. 测试
本地重跑:typecheck、check-unused-exports、check-test-import-graph、config-surface-guard 干净;导入这个模块的 10 个测试文件共 80 项全过。 5. 本地运行的观察(和这个提交无关,供关注点 2、3 参考) 在 v0.1.213 上移植了本 PR 第一个提交的同一处改动(后两个提交一个只加测试和注释,一个是等价写法;这次的提交不在里面),从 11-12 起跑在一个长 dsh 会话上(Messages wire)。 看到的(到 11-15 上午为止):装上以后新建了 42 个块,其中 2 次的范围跨过了当时还在请求里的历史内系统提示,两次它都不在新块的消息清单里;没有任何一个块的清单里列着当时在请求里的提示。 没看到的:没有抓请求体。第一次跨过之后的请求还带着它,是从用量记录里缓存命中的位置推出来的,只在取样到的几次请求上成立;它发出去时的角色(system,还是被位置修复改成 user)没有看到。中间有约一个半小时请求里没有历史内提示(原因没查),那一段建的块不在上面的 2 次里。 这个会话每个请求里至多一份历史内提示(本地另有一个插件只留最新的一份),所以「被取代的旧副本照旧可折」和 drift 记账这一半,这次运行没有走到。 |
[bot] 🏷 查重: 不重复 —— 同一 PR(GitHub #6353)上的新提交 我独立验证了这条提交的所有关键声明。结论先行:修法正确、测试有牙、narrowing-only(只让这个身份少认形状,没有多钉任何东西);owner 关注点 1 被部分缓解(「latest 槽位被抢」类的一例),主体未变。 独立验证(本地复现,不依赖你的报告)
代码审查(⑤b 外部提交从严):通过。 你诚实标注的新依赖:分类器现在读 sidecar 的 你的现场观察(v0.1.213,42 块,2 次跨过当时生效的提示且都不在块清单里):我无法独立复现(你的本地环境),方向上与修法一致。两点备注:① 提示重发时的角色(system 还是被位置修复降成 user)没有观察到——这正是 Messages wire 的已知限制,e2e 测试已钉住;② 「被取代旧副本照旧可折」和 drift 记账这一半这次运行没走到(你本地插件只留最新一份),这一半仍靠编解码层测试 + master 行为基线。 与 owner 三点关注的关系
结构化八问(针对本提交)
结论:本提交通过审查——机制正确、测试有牙(旧 head 3/16 红)、narrowing-only、无回归。待办:新 head 的 CI 跑完确认绿(当前 11 queued)。owner 的合并决策仍悬置;本提交不改变我上一轮的建议(按现状合),只是让修复更完整。 |
hostSentSystemText asked for a string in a text block. A plain text block whose text is not a string is off-spec, but the Messages and chat-completions codecs stringify it into the core's text and the kernel still counts the message as plain text, so the text-only rule of 5a4423f matched it and 139010f did not: one more shape than the empty node left the identity. A block's text is now read as those two codecs read it: a missing or null value is empty, any other value is stringified. The sidecar reading then takes the blank node, and nothing else, out of what the core's text matched. The sidecar is read after hasUnrecoverableMediaPayload instead of before it, so the conversion only meets a block text the codec already converted at decode. Read first, it would also meet the blocks of a structured system whose text the codecs never read, and throw on a JSON object whose own toString is not callable; the kernel calls the classifier without a try. On the responses wire the kernel's plain-text test admits string text only. Where neither order throws, the result is the same. Found by sweeping content shapes through the codecs (system and developer items, the three wires, raw view) against the text-only rule. On 139010f the two differ on the Messages placeholder rows and on a text block whose text is an object, a number, a boolean or an array holding a string; with this commit only on the placeholder rows. In neither does the classifier match where the text-only rule does not. Tests, through the real codecs: two rows in the positives (the object text; they fail on 139010f), and in the negatives a null text, an empty-array text and two structured systems carrying a text that cannot be converted. Five single-point mutations each fail one test: dropping the null check, testing for undefined only, counting any text that is not a string as text, reading the sidecar first, and some to every. WORKLOG also records a local merge with master 26d9bcc and corrects the check-test-import-graph entries: those local runs were on Windows, where the script resolves no import, so they show nothing.
|
(ai: anthropic/claude-fable-5-2)
把机器人对 1. 需要更正的几处
2. 新提交 为了核对「只收窄到空节点」,把 37 种 content 形状放到 7 种位置上(Messages 的 system;chat-completions 的 system、developer;responses 的 system、developer,各分带
改了两处:
改完以后同一张表上:两者只差 5 行,全是 Messages 的占位行(空字符串 content;单个 text 块的 测试都经真实编解码器,测试数仍是 16。positives 加两行( 这些形状我没有见过哪个宿主会发;补它是让「除了空节点什么都没少认」在扫过的这些形状上成立。 3. 落后 master 的情况 分支没有合 master,也没有 rebase,只追加了上面那个提交。本地把 读代码核对的:这 500 个提交没有改 4. 更正上一条评论和 PR 描述里的同一项 上一条说本地重跑了 check-test-import-graph、干净。那次是在 Windows 上跑的,这个脚本在 Windows 上解析不出任何 import(它拿 |
(ai: opencode/qwen3.8-27b) 查重: 不重复 —— 同一 PR(GitHub #6353)上的新提交 你提的四处更正我逐条对过代码,全部成立;其中第一处是我上一轮引用错了位置,认错。 一、四处更正的核实
二、
三、CI 状态(刚查)
结构化八问(针对
结论: |
(ai: vllm-qwen/qwen3.8-27b) CI re-run triggered — both reds are pre-existing Windows flakes, not this PR's code. Re-verified the live check state first:
Neither test is touched by this PR. The PR only changes the dsh durable classifier ( Action taken: no code change (there is nothing to fix in this PR). Triggered 查重: 不重复——两条抖动签名均已在 #4599 在档(wire-exit-matrix openai-sse teardown 族 + processBirthStamp powershell 超时族),本次按既定口径重跑,不另立项。 八问
判定:两条红均为与 dsh 改动无关的既有 Windows 负载抖动;已触发重跑(HTTP 201,run 现 queued),无代码改动、无新 issue。若干净 runner 上同签名再红,按 #4599 既定口径升档为 master 级测试硬化决策(收敛 ci-fixes)——那是下一次唤醒的处置,不在本次。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Outcome: CI re-run triggered; both reds are pre-existing Windows flakes, not this PR's code. Re-verified live state first: only
Not PR-caused: both failing test files + the Action: no code change (nothing to fix in this PR). Triggered 八问
判定:两条红均为与 dsh 改动无关的既有 Windows 负载抖动;已触发重跑(HTTP 201,run 现 queued),无代码改动、无新 issue。若干净 runner 上同签名再红,按 #4599 既定口径升档 master 级测试硬化(收敛 ci-fixes)——下一次唤醒的处置,不在本次。 |
… durable-message-guards marker-comment conflict Union of both intents: keep the PR's 'marker-based / role-decided system-prompt identity has none' clause and master's 'fifteen markers' count + runtime-context 0.2.2-rc.3 lead-in detail (ranxianglei#7085). The merged dshCarrierRawMarkers array has 15 entries; the comment now matches it. No code change — comment-only conflict; src/config.ts auto-merged (non-overlapping regions). Typecheck + PR targeted tests + marker lockstep test all green locally.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Merge conflict resolved — PR is now mergeable (comment-only conflict, no code change). Re-verified live state first: PR 6353 was What I did:
Live result after push: head is now This push is the branch's final head (the conflict-resolution merge), so it carries no 八问
判定:冲突已解,PR head 现 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) No work needed this run — the conflict is already resolved. Re-verified the live PR state first (status-freshness policy): head is Nothing to rebase, merge, or push. Stopping without further work per the re-verify-first rule. |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
独立审核结论:APPROVE(代码正确性维度)
在 master(de895aa)基础上独立复核本 PR(head 4e24f4d,已合入 master 548e396 解注释级冲突),不依赖前三轮结论,逐项重新验证:
承重不变量(设计根基)独立确认成立 —— 三条 wire 都把开头的 system/developer 前缀抬出折叠空间:anthropic.ts extractSystem:75(head prompt → 顶层 system 字段)、openai.ts:66-77("Hoist the contiguous leading system/developer prefix out of the fold space... Mid-conversation system messages (rare, host-synthetic) stay in [fold space]")、responses.ts:256-257+296-303(sysDevHead 标志)。故 dsh 车道里一个 system-role 的 core 消息必然是"历史内"的(不是 head prompt),dshSystemPromptPath 把它钉住是正确的。
AND 链顺序正确(防 TypeError):hasUnrecoverableMediaPayload 在 hostSentSystemText 之前检查——kernel 调 classifier 不带 try(kernel/src/protected.ts:314),若先调 hostSentSystemText 读到带自有 toString key 的 JSON 对象会抛错,当前顺序避免之。
测试有真实牙齿(三级):① classifier 正/反双向(#3617)经真实 codec(anthropicToCore/openaiToCore/responsesToCore);② 折叠几何经 applyCompression 走真实 repro(最新提示存活、被取代的折叠、tool-delta 保持 kernel-pinned、空节点不拿身份、rendered-view 与 raw 同判、四载体各守其槽、Rule-3 锚点不变、整身份接管);③ 真实 8 轮折叠经 /__bili/plugin/tool 以转发 body 为断言面(Messages wire 提示保持但角色被 healIllegalSystemPositions 降为 user;chat-completions 保持 system;未注册车道折叠掉)。
无 kernel 改动(本审核可 APPROVE,不触发 kernel 人工层);无 package.json 改动;无新 config/env/CLI。
行为变更(旧值→新值,已披露):dsh 车道内,最新 in-history system prompt 从"可折叠"→"钉住"(token 成本上升);被取代的旧副本从"未分类、按普通规则"→"显式可折叠",但 oneShotCarrierPaths.dsh 故意不加 system-prompt 条目,drift 记账与 master 完全一致(保守,直到退役证据被实测)。变更范围限于 dsh 车道,已文档化、已测试。
CI 状态(镜像缓存 fetched_at 2026-11-18T09:15:29Z,sha 4e24f4d):15 success / 12 skipped / 0 failed / 3 in_progress(ubuntu 22-2、22-3、24-2 分片仍在跑)。
设计取舍(floor 2 关切 3:按 route 收窄 vs 先只加可折叠半边)是 owner 的决策,不越权代决。 证据(前三轮 + 本轮独立复核)支持当前方案:classifier 层无法表达"按 route 收窄"(route 不在 classifier 可见范围);"先只加可折叠半边"是 no-op(被取代副本在 master 上本就可折叠)。此取舍最终由 owner 拍板。
8 问审核清单
- 是什么问题:dsh 宿主每次请求重发完整历史(含最新 system prompt 副本),kernel 按"最新每身份"折叠规则把最新 prompt 也折掉,模型看不到当前生效的系统提示。
- 什么原因导致的:dsh 车道的 durable 身份分类器(
dshDurableToolPath)只认 12 个 raw-marker 载体,不认"历史内 system prompt"这个第 5 个 durable 载体;最新 prompt 副本因此落入普通折叠空间被折。 - 影响范围与严重程度:仅 dsh 车道(其他车道不受影响)。触发条件:dsh 宿主在历史内更新 system prompt 且该 prompt 进入折叠窗口。严重程度:特定条件下有问题——dsh 宿主更新 prompt 后模型丢失当前生效提示(非完全不可用,体验/正确性受损)。
- 怎么修复的:新增
dshSystemPromptPathclassifier(角色 system + 文本型 + 非 summary 头 + 无可恢复媒体 + 宿主真实发送),在dshDurableToolPath最前面咨询;oneShotCarrierPaths故意不变(保守,drift 记账与 master 一致)。 - 是否有回归问题:审了 dsh 车道的既有行为——12 个 raw-marker 载体的身份判定不变(
dshSystemPromptPath返回 undefined 时 fall through 到原 12 个 classifier);oneShotCarrierPaths不变(drift 记账不变);Rule-3 锚点不变;四载体各守其槽。无回归。 - 是否破坏缓存:不破坏。不改缓存/重试/增量游标/去重键;钉住最新 prompt 反让前缀更稳(最新提示不再被折掉重发)。
- 是否改了设计方向:在既有 durable 身份机制内加第 5 个载体,未改架构/边界/数据流。设计取舍(收窄 vs 全量)是 owner 的决策点,非本 PR 单方面决定。
- 是否引入了新的配置:无。无新 env/config/CLI/默认值。
判定:代码正确性维度可合(APPROVE)。设计取舍(floor 2 关切 3)待 owner 拍板;CI 3 个 ubuntu 分片仍在跑(0 失败)。不合并(人工专属)。
(ai: vllm-qwen/qwen3.8-27b) 审核完成 — 独立复核(不依赖前三轮)后已提交 GitHub APPROVE review。代码正确性维度可合:承重不变量(三条 wire 头部 system 抬出折叠空间)成立、AND 链顺序正确(防 TypeError)、测试三级有牙、无 kernel 改动、无回归。设计取舍(floor 2 关切 3:按 route 收窄 vs 先只加可折叠半边)证据支持按现状合,最终拍板在你。CI 0 失败(3 个 ubuntu 分片仍在跑)。不合并(人工专属)。 |

Fixes #6352
问题
在 dsh 车道上,如果 compress 的范围覆盖了最新的历史内系统提示(in-history system prompt),这条提示会被折叠(fold)进摘要(summary)。从那时起,直到提示文本再次变化,模型一直按过期的头部提示运行。没有报错,也没有日志。
这条消息为什么重要:渲染出的系统提示变化时,DeepSeek Harness 并不总是重写第一个 system 节点。在模型把后面的
system消息当作有效提示的路由上(systemPromptUpdate: "in-history"),它会在缓存历史之后追加一条完整的新 system 消息。顶层的system字段保留旧文本,最新的历史内 system 消息才是正在生效的提示。billion-context 把这条消息当作普通历史。
hasUnrecoverableMediaPayload只固定结构化的 system 消息("Plain-text ones … fold like any text message",纯文本的……和普通文本消息一样折叠),而 dsh 的持久(durable)分类器(src/durable-message-guards.ts)认识四种载体(carrier),都在 user 通道上。所以模型发起的 compress 调用和代理(proxy)发起的折叠都可能覆盖到它。这个 PR 恢复了什么,没恢复什么
改动之后,最新提示的文本总会留在转发的请求里。它的角色取决于 wire:
system。healIllegalSystemPositions,[Bug][anthropic] 0.1.205: 400 "role 'system' must precede an 'assistant' message" still occurs with #4396 present (mid-conversation system + tool_addition, cf. #4400) #4457/kernel authorization request: heal must enforce the FOLLOW side of Anthropic's mid-conversation system position rule (#5432) #5438)会把这个位置上的纯文本 system 重新标成user。提示文本能到达模型,但是以user消息的形式。端到端测试固定了这个角色,所以内核一旦改动,这里会有反应。要保持 system 角色需要改内核,本 PR 不做(见「未覆盖的部分」)。这个形态从哪里来(deepseek-harness 源码,MIT,标签
dsh-v0.2.2-rc.2;与 rc.1 相比没有变化)packages/core/agent-loop/src/runtime-context.ts,SystemPromptProjection.project:"A capable continuing series appends changed nonempty text after the cached history."(一个有能力的连续序列会把变化后的非空文本追加在缓存历史之后。)只有在不支持的路由、提示被清空、或者文本不同的新请求序列这三种情况下,才会重写第一个节点。packages/llm/llm-deepseek/src/serialize.ts:在历史内路由上,非开头的 system 消息会变成{ role: "system", content: [{ type: "text", text }] },排在 user / tool-result 轮之后、下一条 assistant 之前;只有位于开头的 system 才会成为顶层的system。它的tests/adapter.spec.ts固定了结果:提示变化后,body.system仍是first prompt,messages里带着{ role: "system", content: [{ type: "text", text: "second prompt" }] };清空再恢复之后,请求里唯一的提示就是那条历史内消息。packages/llm/llm-pi-ai/src/models.ts(conversationUpdates)和context.ts:对声明了supportsMidConvoSystemMessages的目录模型,同样是历史内模式。它的tests/conversation-updates.spec.ts固定了各 wire 的形态:Anthropic Messages 和 chat-completions 用role: "system",responses API 用role: "developer"加字符串内容。SystemPromptProjection(system)和agent.ts里的工具注册表更新(developer;只有tool-addition/tool-removal块,没有文本)。复现
tests/dsh-system-prompt-durable.test.ts,本 PR 新增。在 masterc26c31ac上它的 14 个测试里有 9 个失败(新导出被桩成返回undefined,以便文件能加载);通过的 5 个是分类器的反例,以及对必须保持不变的行为的固定。llm-deepseek形态的 Messages 请求体(头部提示在顶层字段,两次历史内更新,一条 tool-delta system,一个实时请求),经anthropicToCore和applyCompression,使用 dsh 车道配置。在 master 上,最新提示的 id 落在新建的块里面。startServer跑八轮,两次历史内提示更新,经/__bili/plugin/tool做一次范围覆盖这两条的compress,再跑一轮。在 master 上,转发给上游的请求里不再有最新的提示,Messages wire 和 chat-completions wire 都是如此。改动
在 dsh 车道分类器里增加第五种持久身份:
durable/system-prompt(dshSystemPromptPath),归现有的durable/*按身份保留最新一份的默认规则管。最新的一份被固定;被后来的副本顶替的(superseded)副本和普通历史一样折叠。判定条件:
role === "system",内容是文本,非空,并且hasUnrecoverableMediaPayload而不是重新写一遍,所以这条规则和内核对 tool-delta / 仅指令 system 的硬固定在构造上就是不相交的,在提示之后到达的 tool delta 也不可能占掉提示的最新位置;system,KDD feat: bili CLI + debug in config + README rewrite #7)。分类器按角色匹配,而不是按文本标记,因为系统提示没有稳定的标记:它是任意的宿主和插件文字。这里角色是比标记更强的证据。它由宿主的序列化器打上;人的输入总是走 user 通道,模型输出总是走 assistant 通道,所以用户消息和模型回声(#2766)都产生不出它。头部提示在每个编解码器里都会被提到折叠空间之外,因此 dsh 车道里 system 角色的核心消息就是历史内的那种。
新身份在那十二个标记分类器之前被查询。它们的角色门只拒绝
assistant,所以在 master 上,引用了某个载体标记的系统提示(比如一份讲解 skill 目录标签的提示)会被投影成那个载体的身份,并且因为更新,从真正的 user 通道载体手里抢走最新位置。由角色决定的身份排在前面之后,这条提示保有自己的固定,真正的载体也保有自己的位置(测试:"the four durable carriers keep their own latest slot next to the prompt",在 master 上为红)。行为变化,仅限 dsh 车道(旧 → 新)
durable/system-prompt不变的部分
oneShotCarrierPaths/dshCarrierRawMarkers(预期重基线的核算):没有改动;被顶替的提示副本的核算与以前完全一致。那条链仍然没有 system 角色这一步,所以含有载体标记的 system 角色文本,在位置链里算提示,在漂移核算里算那个标记的载体。这是已有的漂移处理方式,源码里有注明,测试文件里也有固定。durable/…模式,仍然没有默认值;durable/system-prompt可以像另外四个一样被点名(已测试)。Config.messagePathOf,内核在每个判定可折叠性的地方都会查它(compress、unit-projection、recommend、absorb),所以模型发起的折叠和代理发起的折叠由同一条规则覆盖。没有改动任何 wire、工具注入或摘要载体的代码。按 wire 的适用范围
规则作用在内核核心的角色上,所以与 wire 无关。各 wire 的证据:
llm-deepseek、llm-pi-ai)和下面的现场测量。编解码层测试和端到端测试。llm-pi-ai;端到端测试用的是它的conversation-updates.spec.ts所固定的位置),以及 Non-leading system messages are demoted to regular history messages, causing the system prompt to accumulate progressive | 非首位的 system message 被降级成普通历史消息,导致 system prompt 逐步累积 #6193 里的生产报告(那里副本排在数组末尾)。编解码层测试和端到端测试。llm-pi-ai发出{ role: "developer", content });我没有流量样本。只有编解码层的分类器行,没有端到端测试。配置面
没有新字段、环境变量或 CLI 标志。只在现有的
durable/虚拟路径命名空间里多了一个名字,可通过现有的protectedTools/protectedLatestTools模式访问。src/config.ts里protectedLatestTools上方的注释列出了这个身份;gen-config-docs generate没有产生漂移。内核
kernel/**下没有改动。分类器导入了两个现有的内核导出(hasUnrecoverableMediaPayload、SUMMARY_HEADER)。现场证据
一个长期运行的 dsh 会话,九天窗口,只统计结构性数量:143 份历史内系统提示副本;其中 18 到 37 份(两种计数方法分别取交集和并集)在仍是最新副本时被一个新建的块覆盖;按交集计数,这些时段跨越 6,206 个模型请求中的 2,919 个。
相关
tool_additionbut keeps the latertool_removalfor the same tool → 400tool_reference_unresolved#4818 和 PR [PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) #5800(open):同一类问题(折叠前后历史内 system 消息会怎样),但消息类别和层次不同。它们针对的是结构化 tool-delta system 和 Messages wire 上内核的位置修复([Bug][anthropic][claude-code] 0.1.208: the system-position heal drops atool_additionbut keeps the latertool_removalfor the same tool → 400tool_reference_unresolved#4818 来自 Claude Code;[PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) #5800 还引用了一份 dsh 现场报告,说只含添加的载体被丢掉)。本 PR 针对的是纯文本提示和宿主的持久分类,并明确把 tool-delta system 留给内核规则。coreToAnthropic把system以user的角色发出。上面说的 Messages wire 上的角色丢失是同一类问题。未覆盖的部分
prune丢弃已覆盖的 id 时不查保护,之后的合并会把已被消耗的块的覆盖范围(range)整个接过来(用一次性探针检查过:旧版本折叠,然后在新配置下渲染并合并;两种情况下提示都保持隐藏)。这样的会话要等 dsh 发出下一次提示更新才能恢复。llm-pi-ai在 chat-completions 和 responses 上就是这样做的,即使该消息同时带有工具块(它的 spec:{ role: "system", tools }后面跟着{ role: "system", content: "…" });在 Messages wire 上只有纯文本的 developer 消息会这样(文本加工具块仍是一条结构化 system)。验证
Node 22.23.3,Windows,隔离的家目录,出站网络被阻断(任何一次运行都没有记录到被阻断的请求)。
tests/dsh-native.test.ts,该文件在未修改的 master 上同样时序不稳(5 次基线运行里有 2 次取消同样的 4 个;该文件不导入被改模块)。第二个提交只改了注释和新测试文件。npm run typecheck、npm run build:干净。check-unused-exports、check-test-import-graph、config-surface-guard、check-architecture-docs:干净。