Skip to content

DSH: The skill body <skill_content> is not protected by the classifier and gets collapsed in long conversations. | DSH: skill 正文 <skill_content> 未被分类器保护,长会话中被折叠 #7264

Open

Description

@guagua159

现象

在 DeepSeek Harness (DSH) 桌面端主动调用 skill(如 /prompt-refiner)后,长会话里模型明显"忘了"技能里的程序化步骤,只保留了标题级的骨架要点。用户感知为"调用 skill 被忽略"。

排查后发现:skill 的目录被保护了,但 skill 正文(<skill_content> 全文)没有。

环境

  • dsh desktop(run_code-only 工具面,ACP 工具不上 wire)
  • billion-context 0.1.216
  • 配置 ~/.config/billion-context/billion-context.json:
{"compress":{"promptPack":"lean","preserveRecentMessages":4,"preserveRecentTokens":6000,"minCompressRangeChars":5500,"maxContextLimit":"75%"}}

(未设置任何 protectedTools / protectedLatestTools / neverPreserveRecentTools)

取证

1. skill 正文是纯文本消息,不是 tool-result

统计本机 51 份 dump(~/.local/state/billion-context/dumps/):

  • 全部 tool_use 名称统计:{"run_code": 658} —— 请求体里根本没有名为 skill 的工具调用
  • <skill_content> 出现 73 处,全部落在 text 块,0 处落在 tool_result
  • 21 个长会话(消息数 > 10)全部 <available_skills> 目录存活(catalog: 1)

即:DSH 把 skill 装载结果作为 user 角色的一条文本消息注入,和多段插件注入拼在同一个 content 数组里(实测一条 message 内 16 个 text 块:用户原文 / workspace instructions / runtime context / plugin context / skill catalog / skill 正文 / time-context / 9 段压缩摘要)。

2. 分类器清单里没有 skill 正文

dist/index.js 中 dsh lane 的 withDurableProtection 自动挂 protectedLatestTools: ["durable/*"] + messagePathOf,其分类器共 12 个:

标记 虚拟路径
<available_skills> durable/skill-catalog
Instructions from: durable/agents-md
Current runtime context durable/runtime-context
<mcp_catalog> durable/mcp-catalog
time-context / ptc-image / tool-job-notice / mnemon / subagent-settled / agent-relay / image-handle / image-offload-placeholder oneshot/*

dshCarrierRawMarkers 也不含任何 skill 正文标记。

上游 master 的 src/durable-message-guards.ts(当前 28,990 字节)同样只有上述 12 个 export function,没有 <skill_content> 的分类器。

3. protectedTools 无法补救

function matchToolMessagePattern(msg, pattern) {
  const toolName = msg.toolName ?? "";
  if (!toolName) return false;   // 纯文本消息直接出局
  ...
}

isMessageProtected 里纯文本消息只能通过 virtualToolPathOf(msg, config) → config.messagePathOf 产出的虚拟路径命中 protectedTools,而 messagePathOf 由插件内部注入,用户配置无法提供。因此文档 docs/configuration.md:1561-1570 里的 protectedTools: ["skill"] / ["skill/<name>"] 在 DSH 场景下是 no-op。

4. 折叠现场

样例 req-1794840657165-*.json 中同时存在:

  • <skill_content name="prompt-refiner"> 正文 7192 字符(当次新装载,还在)
  • 同一消息里另一条 1258 字符的 [Compressed conversation section] 摘要,标题正是「prompt-refiner 技能全文、首轮目录侦察」——只剩六槽提纲、输出格式三条、预交付检查七问,程序化的输入分类规则和例子策略全部丢失

以后一次装载的到来为界,旧装载已被折掉。

与 #2419 的关系

#2419(「开启 bili 后「规矩与 skill 好像没被使用」?」)与随后的 #2428 修的是 skill catalog(dshSkillCatalogGuard,按 msg.text.includes("<available_skills>") 硬保护整条消息)。本轮取证确认这部分已生效(长会话 catalog 100% 存活),但正文装载没有任何守护,长会话中一次 7K 字符的技能正文迟早被折成 1~1.3K 的摘要,等价于"技能没用上"。

建议

  1. 在 src/durable-message-guards.ts 增加一个分类器,例如:
const SKILL_CONTENT_RE = /<skill_content\s+name=/;
export function dshSkillLoadPath(msg) {
  if (msg.role !== "user") return undefined;
  return SKILL_CONTENT_RE.test(msg.text) ? "durable/skill-load" : undefined;
}

并入 createDshClassifier / dsh 分类器链,同时在 dshCarrierRawMarkers 里补 "<skill_content"。

  1. 注意一条 message 内可能同时承载「用户原文 + 多个载体 + skill 正文」。若按整条消息分类,会把这整条 16 块消息钉死(其中含真实用户输入与后续摘要),建议分类器粒度做到 block 级,只固定 <skill_content> 那个 text 块;否则用整条保护会显著增加不可压缩体积。

  2. 顺带:<skill_content> 不在 dshCarrierRawMarkers 中,lastUserAnchor() 目前会把它当真实用户消息抢锚点(与 [Bug][dsh] lastUserAnchor only guesses injection by text prefix — any new plugin's role:user injection will hijack the p | [Bug][dsh] lastUserAnchor 只按文本前缀猜注入 —— 任何新插件的 role:user 注入都会抢走保护区锚点 #6129 同族,长会话 reanchor 后可能"回答上一条")。补上标记可一并消除。

临时规避

用户侧只能升级目录保护("compress": {"protectedTools": ["durable/*"]} 走 classified 分支),对正文无效。正文必须靠上游分类器。

Activity

  1. changed the title [-]DSH: skill 正文 <skill_content> 未被分类器保护,长会话中被折叠[/-] [+]DSH: The skill body <skill_content> is not protected by the classifier and gets collapsed in long conversations. | DSH: skill 正文 <skill_content> 未被分类器保护,长会话中被折叠[/+] on Nov 19, 2026
  2. ranxianglei commented on Nov 19, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    [bot] 🏷

    查重: 不重复

    检索了 open + closed 的 issue 和 PR(skill / durable / skill_content / classifier / catalog):

    结论:skill 正文 <skill_content> 未被分类器保护是独立的新缺口。

    Triage 三步(已对上游 master 代码验证):

    1. 复现/查证:读了 src/durable-message-guards.ts(474 行),确认 12 个分类器(4 durable + 8 oneshot)里没有 <skill_content> 分类器;dshCarrierRawMarkers(15 个 marker)里也没有。matchToolMessagePattern(kernel/src/protected.ts:286)对无 toolName 的纯文本消息直接 return false,所以 protectedTools: ["skill"] 在 DSH 场景确实是 no-op。bug 真实存在。
    2. 定位层次:根本原因是分类器清单缺 skill 正文这一档——DSH 把 skill 装载结果作为 user 角色纯文本消息注入(不是 tool-result),而 durable 保护只认 messagePathOf 分类器产出的虚拟路径,用户配置无法提供。表面现象是"长会话里技能步骤被折成摘要"。
    3. 方案评估:issue 建议的方向(加 durable/skill-load 分类器 + 补 marker)打到了核心。一个关键澄清:block 级粒度已经天然满足——openaiToCore(kernel/src/wire/openai.ts:112,The intermediate message (core) is not protocol-agnostic: switching protocols/models causes identity churn; cross-protoc | 中间消息(core)没有做到协议无关:切协议/切模型制造身份 churn,补齐跨协议映射 #3642 canonical granularity)把 user 消息的每个 content part 拆成独立 core,所以分类器只会命中承载 <skill_content> 的那一个 core,不会把整条 16 块消息钉死。issue 担心的"整条保护"在现行 wire 转换下不会发生。

    计划:

    1. src/durable-message-guards.ts 加 dshSkillLoadPath 分类器(匹配 <skill_content name=,role 门同其余 12 个:role !== "assistant"),投影到 durable/skill-load,并入 dshDurableToolPath + oneShotCarrierPaths.dsh 两条链。
    2. dshCarrierRawMarkers 补 <skill_content name=——一并修掉第 3 点的抢锚点(分类器侧)+ side-request 误路由(carriesDurableState,side-request.ts:360)+ 折叠漂移记账(fold-reconcile.ts:1877)。
    3. 更新 lockstep 测试 + 加回归测试。
    4. 定向 typecheck + 测试 → 提 PR(Closes DSH: The skill body <skill_content> is not protected by the classifier and gets collapsed in long conversations. | DSH: skill 正文 <skill_content> 未被分类器保护,长会话中被折叠 #7264)。

    开始实现。

  3. ranxianglei commented on Nov 19, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

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

    查重

    不重复。#2419/#2428 修的是 skill 目录(dshSkillCatalogGuard,<available_skills>),本轮取证确认目录守护已生效(长会话 catalog 100% 存活),但正文装载没有任何守护——这是独立的新缺口。

    已修复 — PR #7268

    #7268

    本地定向验证:npm run typecheck 干净;新增 tests/issue7264-dsh-skill-load.test.ts + 既有 issue5142/issue2419/issue2766/durable-tool-identity/side-request/fold-reconcile 共 188 个测试全绿。PR 已开,CI 在跑(合并判定以远程 CI test lane 为准)。

    结构化八问

    1. 是什么问题:DSH 调用 skill 时注入的正文(<skill_content> 全文)是普通 user 角色文本消息,但 dsh 分类器清单里没有它的条目,长会话里一次折叠就把 7K 字符的技能正文折成 1~1.3K 摘要,模型"忘了"技能里的程序化步骤(用户感知为"调用 skill 被忽略")。

    2. 什么原因导致的:根本原因是 src/durable-message-guards.ts 的 dsh 分类器链只有 12 个分类器(4 durable + 8 oneshot),唯独没有 skill 正文。skill 目录(开启 bili 后「规矩与 skill 好像没被使用」? #2419)有守护,正文装载没有。宿主每次调用只装载一次正文且不重发(与目录的指纹门不同),所以一次折叠就永久杀死技能步骤——开启 bili 后「规矩与 skill 好像没被使用」? #2419 的失败模式在正文信道上的翻版。

    3. 影响范围与严重程度:受影响 = 所有用 DSH 桌面端主动调用 skill 的长会话用户;触发条件 = 会话长到折叠范围位置性覆盖 skill 正文。严重程度 = 技能功能在长会话中退化,但会话本身仍可用、重新调用技能即可恢复,故 p2(能用但有明显问题),非 p1(非会话不可用/数据丢失类)。

    4. 怎么修复的:新增 dshSkillLoadPath 分类器,把 skill 正文投影为 durable/skill-load,让默认 latest-per-identity 策略钉住最近装载的技能正文、被取代的旧装载正常折叠。匹配用特征标签前缀 <skill_content name=(name 属性值可变,整标签不能是定长串)。同时把标记补进 dshCarrierRawMarkers(side-request 路由 + drift 记账)和 oneShotCarrierPaths.dsh。block 级粒度已由 The intermediate message (core) is not protocol-agnostic: switching protocols/models causes identity churn; cross-protoc | 中间消息(core)没有做到协议无关:切协议/切模型制造身份 churn,补齐跨协议映射 #3642 满足(openai wire 每个 content part 独立成 core),分类器只命中 skill 正文那个 core,不会钉死整条 16 块消息(含真实用户输入与后续摘要)。

    5. 是否有回归问题:无。这是给原本无保护的载体新增保护,不改变任何既有行为——skill 正文从"会被折掉"变为"latest-per-identity 钉住"。无配置面变更、无模型面文本变更、无 kernel 变更、无 wire/协议变更。lane 隔离(KDD release v0.1.2 #9 证据白名单):分类器仅 dsh,未注册 lane 仍折掉(测试钉死)。

    6. 是否破坏缓存:不涉及。不触碰缓存/重试/增量游标/去重键。

    7. 是否改了设计方向:不涉及。沿用现有 durable 载体 + latest-per-identity 策略,无架构/边界/数据流转向。

    8. 是否引入了新的配置:不涉及。无新 env/config/默认值。保护对 dsh lane 自动生效(走现有 durable/* 策略),用户无需任何配置。

    一处取证勘误

    issue 第 3 点说"补上 dshCarrierRawMarkers 标记可消除 lastUserAnchor() 抢锚点"——略不精确:抢锚点的修复来自分类器(lastUserAnchor 跳过 virtualToolPathOf(msg) !== undefined 的消息,即 messagePathOf 产出的虚拟路径),而 dshCarrierRawMarkers 修的是 side-request 路由(carriesDurableState)+ drift 记账(hasCarrierMarker)。本 PR 两者都补了,所以抢锚点确实一并消除(由分类器完成),标记补的是另外两个消费方。

    顺手修

    • tests/issue5142-expected-rebase.test.ts:472 lockstep 断言 >= 15 → >= 16(13 个 dsh 载体家族),随新增分类器同步,commit 已含。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions