Skip to content

The compress failure receipt is self-contradictory: the same message first declares the ref permanently DEAD, then lists the range containing that DEAD ref as the "current compressible range." | compress 失败回执自相矛盾:同一条消息先宣告 ref 永久 DEAD,再把含该 DEAD ref 的区间列为「当前可压缩范围」 #3192

Closed

Description

@iuuuuuuuu

bili version

0.1.196(回执实测版本)/ 0.1.197(当前最新 release;同一代码路径未变,见下)

Usage mode

Plugin native(bili 作为 dsh 插件的代理实例运行,bundle 托管,跳过 in-place 自更新)。

Client and version

DeepSeek Harness (dsh),OpenAI 兼容协议,客户端流式(SSE)。

Operating system

Windows 11(非 WSL2),Node 22+。

Upstream and model

OpenAI 兼容聚合端点,模型 deepseek-v4.1-flash。

Compression-related config

全部默认。未设置 compress.minCompressRange、compress.preserveRecentMessages、plugin.snapshotCapBytes。


问题

一条 compress 失败回执会在同一条消息内同时说两件互斥的事:

  1. 这些 ref 已被永久记为 DEAD,任何包含它们的区间永远压不了;
  2. 「当前可压缩范围」正是那个包含 DEAD ref 的区间,并让模型用它。

这不是「提示不够准」,而是回执内部自相矛盾,且矛盾的两半出自两个不同的计算源。

实测回执(原文,已脱敏)

2026-10-13 20:14:54,一个 60 可见消息 / 5 active block 的会话,0.1.196:

[Compression FAILED: Requested range(s) cannot be anchored (e.g. m11615..m11620): refs m11620
are known to this session but no longer back any visible or folded message — the client rewrote
or dropped those messages (an edit reissues a new ref; host-native compaction or a bulk history
rewrite drops them outright), and no active block covers them. These refs are now recorded as
DEAD: no range that includes them can compress now or later, whatever the neighbors. Do not
retry this range in any form — run acp_status and target only the live refs it reports.
[diagnostics: session highest ref=m11637, unknown ranges in request=0/1, session history=7
compression(s), 7 block(s)] [cause: content-changed — the messages behind those refs changed
and carry new refs now] [Current context: 60 visible message(s), refs m11249–m11637, 5 active
block(s). Refs restart at m00001 after a session-generation change — request only refs inside
this span, or call acp_status for exact compressible ranges.]]
Current compressible ranges (use these refs exactly as listed):
Compressible ranges (1, oldest first): m11615–m11620  44 msgs  57.8K [tool 68% | text 32%]
Do not repeat the rejected call unchanged; use only the eligible ranges listed here.

三处互斥:

  • 前文:refs m11620 … recorded as DEAD: no range that includes them can compress now or later
  • 前文:Do not retry this range in any form
  • 后文:use these refs exactly as listed: m11615–m11620

m11615–m11620 包含 m11620 —— 正是被同一段话宣告「永远不可压」的那个 ref。

后果(模型实际被带偏)

同会话下一轮,模型 reasoning 原文:

The compress call failed because refs m11620 is dead. I need to use the correct refs. The tool said compressible range: m11615–m11620 44 msgs 57.8K. But then it said m11620 cannot be anchored. Confusing. Let me call acp_status to see.

But it also says m11620 is dead. Contradiction. Let me just call acp_status to see.

净代价:一次 compress 调用被拒 + 一轮额外 acp_status 往返,纯粹因为回执自相矛盾。这正是 #2778 想消灭的那类「跟着提示走 → 再被拒」的浪费,只是在 DEAD 这一类上又出现了。

根因(代码层)

两个面用了不同的判据:

(a) 施加侧(gate)认 DEAD —— kernel/src/compress.ts 计算 deadRefs,任何包含 DEAD ref 的区间被拒(回执里的 recorded as DEAD 就出自这里)。

(b) 建议侧(hint)完全不看 DEAD —— 0.1.197 的 hint 链路是:

src/stream.ts  compressionRecovery()
  -> liveCompressionRanges(ctx)            // src/acp-status.ts
  -> turn.nudge.compressibleRanges
  -> kernel/src/recommend.ts  buildCompressibleRanges()

buildCompressibleRanges() 只过滤 covered / protected / synthetic-pruned / checkpoint-carrier / unrecoverable-media / integrity-withdrawal,从不读 state.deadRefs(该文件里 dead 出现 0 次)。于是 DEAD ref 照样进 compressibleRanges,hint 原样列出。

补充:这不是 dead 判定本身的问题 —— deadRefs 的语义与 #3137 正在加固的那一支是另一回事。这里是建议侧根本没消费这个状态。

这是 #2778 修复里被丢掉的一半

PR #2800(Use live compression eligibility for recovery advice,Fixes #2778,已 merge)在描述里明确承诺保留四样东西:

Keep single-line receipts, repeat guards, dead-ref exclusion and the existing pre-fold success-tail offer.

但 Excluded as DEAD 这段文本在 0.1.197 的 dist bundle 里已不存在(grep 无命中),而新 hint 的取值来源 buildCompressibleRanges() 没有任何 dead 过滤。旧实现的算术 span 至少还显式补了一句排除:

Excluded as DEAD (N ref(s) whose messages the client no longer sends — they can never compress): mNNNNN, …

也就是说:换成「共享 live 资格计算」之后,protected / covered 这两类确实修好了(#2778 的目标达成),但 DEAD 这一类的排除在重构中静默丢失 —— 新的共享来源自己没有 dead 过滤,而 PR 描述里承诺的 "dead-ref exclusion" 没有测试守住它。

关于引入版本:我在若干 tag 上对 src/stream.ts 做了文本比对,Excluded as DEAD 与 use these refs exactly as listed 的出现情况并不单调,所以不声称一个精确的引入版本。可复现的事实是:0.1.197 的最新 bundle 里两者不同时存在,且新 hint 的来源无 dead 过滤。

建议修法

在共享的资格计算里补 dead 过滤,而不是在 hint 层再拼一段文字:

  1. (首选,kernel) buildCompressibleRanges()(kernel/src/recommend.ts)的跳过判据里加入 state.deadRefs(按 ref 判断,与 gate 同源)。这样 acp_status 的 Compressible ranges 与失败回执 hint 会一起正确,不会再出现「status 说能压 / gate 说 DEAD」的分裂。
  2. (宿主侧规避) 在 liveCompressionRanges() / compressionRecovery() 里对 live.ranges 做一次 dead 过滤;全部被滤掉时落到已有的 " No eligible message ranges are available now; continue the task without compressing." 分支。
  3. 恢复一行显式排除说明(旧 Excluded as DEAD 那类),让模型理解「为什么少了这段」。

注意:方案 1 属 Kernel Boundary,需 owner 批准并按该流程执行(PR 声明 kernel-change:、版本 bump、human-only review、双层测试)。

验收

  • 构造 deadRefs 非空、且某个 DEAD ref 落在某 compressible span 内的 state,触发一次 cannot-anchor 失败:
    • 回执的「当前可压缩范围」不得包含任何 deadRefs 成员;
    • 若过滤后为空,必须走 No eligible message ranges are available now; continue the task without compressing.,而不是列出空集、也不得回退到旧的算术 span。
  • 同一 state 下 acp_status 的 compressible ranges 与失败回执 hint 一致(这是 Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 的核心承诺,目前只在 protected / covered 上成立)。
  • 回归:protected tail / already-covered / sub-minCompressRange / 正常可压区间,四类都不得被 dead 过滤误伤。
  • 门禁必须能真的变红:该用例在未修复的 0.1.197 上必须失败(当前会失败,因为 hint 仍列出 DEAD ref)。

相关

Activity

  1. ranxianglei commented on Oct 14, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

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

    已定位并修复,PR:#3195 (base master)。分支已 rebase 到最新 master,本地定向测试全绿;全量回归交给 CI。

    八问

    1. 是什么问题:一条 compress 失败回执自相矛盾——同一句话里既宣告某 ref「已记为 DEAD,任何包含它的区间现在和将来都压不了」,又把「当前可压缩范围」列成恰好罩住这个 DEAD ref 的区间(你例子里 m11615–m11620 含 m11620)。模型被迫多跑一轮 acp_status 才发现两处对不上。

    2. 什么原因导致的:两段独立计算没对齐。提交闸门(kernel compress.ts)读 state.deadRefs、拒绝引用 DEAD ref 的区间并记账;但「可压缩范围」视图(buildCompressibleRanges)从不读 state.deadRefs。更关键的是它按数组位置分段(不在 ref 编号的空洞处断开),所以中间被客户端删掉的那条消息会留下一个数字洞,被同一个 [startRef..endRef] 区间罩住——DEAD ref 就落进了对外宣称的区间里。这是 Use live compression eligibility for recovery advice #2800(Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 共享来源重构)引入的回归:重构前的提示会排除 DEAD ref,重构后只保留了 protected/covered 两类排除,把 DEAD 那条弄丢了。

    3. 影响范围与严重程度:所有走 ACP compress 的插件/代理会话,当客户端改写或删掉某条消息(其 ref 变 DEAD)、且该 ref 落在某个可压缩区间内时触发。属体验缺陷而非数据损坏——不会压坏东西,但会把一个注定失败的区间再喂给模型一次,浪费一轮往返并制造困惑。严重度:中(特定条件触发)。

    4. 怎么修复的:在宿主侧加纯函数 excludeDeadRefRanges(ranges, deadRefs)——凡是 [startRef..endRef] 罩住任一 DEAD ref 的区间整体剔除,deadRefs 为空时是 no-op。应用在两个对外宣称面:liveCompressionRanges()(同时喂给失败回执提示和 acp_status 的 ranges 段,所以两者天然一致,保住 Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 的核心承诺),以及 post-compress tail offer 的两条分支。全部剔除后,回执落到既有的「No eligible message ranges are available now; continue the task without compressing」停手指令,而不是列一个注定失败的区间。

    5. 是否有回归问题:审过既有行为——protected tail / already-covered / sub-minCompressRange / 正常可压缩区间都不受影响(deadRefs 空时 helper 原样返回)。本地定向套件全绿:recovery-ranges + dead-ref-filter + acp-status + span-hint = 26/26,success-tail = 10/10。新增集成测试在未修复代码上按行为断言变红(不是 import 报错),修复后转绿。无 fail-fast 变吞错、无阈值/时序/输出格式漂移——只是把闸门本就会拒绝的区间从清单里拿掉,不新增也不重排任何存活区间。

    6. 是否破坏缓存:不涉及。改动只在「对外展示哪些区间」这一层,不碰 prefix cache、快照游标、去重键或任何持久化格式。

    7. 是否改了设计方向:不改架构/边界/数据流,是把 Use live compression eligibility for recovery advice #2800 重构时弄丢的一处排除补回宿主侧。更根本的家在 kernel:让 buildCompressibleRanges 自身围绕 DEAD ref 切分(能覆盖其它消费方,还能给出存活的子区间而非整段丢弃)——但那受 Kernel Boundary 约束(需 owner 批准 + 人工审核 + 版本 bump + kernel-change 声明)。宿主侧已完整解决用户可见问题,故不捆绑进本 PR,留作 owner-gated follow-up,此处先说明不擅自改 kernel。

    8. 是否引入了新的配置:不涉及。无新 env/config/CLI 字段。

    行为变更披露(旧→新):失败回执 / acp_status / nudge tail 此前可能列出含 DEAD ref 的区间 → 现在剔除这类区间(若因此清空则输出停手指令)。只移除闸门本就会拒绝的区间,绝不新增或重排存活区间。

    合并判定:可合并。host-only、单模块、带行为断言的回归测试、rebase 后 typecheck + 定向测试全绿;全量以 CI 为准。CI 绿即可合。

  2. ranxianglei commented on Oct 14, 2026

    @ranxianglei
    Owner

    是否和已有issue重复

  3. ranxianglei commented on Oct 14, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    [bot] 回答 owner 质询(查重结论,接单时遗漏——规则缺口已在补):

    查重:不重复,但同家族。 与 #3137/#3141 对比:①症状不同——#3137 是空视图把 ref 误判 DEAD(内部状态污染,#3141 修);本条是回执自相矛盾(DEAD ref 的区间又被列为可压缩,回执文本互斥);②机制不同——#3137 修的是 tombstone 写入语义,本条修的是 buildCompressibleRanges() 的 dead 过滤缺失(计算侧);③报告者场景不同——60 可见消息/5 active block,非空视图,#3141 修不了这个场景。

    冲突风险:PR #3195 与 #3141 都触碰 kernel compress dead-ref 处理——3195 需以 3141 合并后的 master 为 base rebase,两者语义互补(一个管写、一个管读),顺序无依赖但文件有重叠。

    后续接单查重结论必须作为第一条回复(修复开始前)——规则已补。

  4. ranxianglei commented on Oct 14, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

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

    查重结论:不重复。 #3192 与既有的 #3204、#3205、#2778 都不重复——它们是同一根机制(资格视图 buildCompressibleRanges 从不消费 state.deadRefs)下按「产线 / 层次」刻意拆分的三个独立 issue,互补、无重叠。

    三者关系(owner 在 review 我的 PR #3195 后于 16:52Z 主动拆分,各带 来源 标记):

    issue 覆盖面 层次 用户可见症状 状态
    #3192 → PR #3195(本 issue) 失败回执提示、acp_status ranges、post-compress tail 三面 宿主侧 excludeDeadRefRanges 整段剔除 单条回执自我矛盾:同一条消息既宣告 ref 永久 DEAD、又把含它的区间列为可压缩 PR 已提,待 CI
    #3204(owner 立) nudge 决策指令面 + /acp 面板字段 宿主侧,复用 #3195 的 helper 跨面不一致 + nudge 指令注定失败(面板 vs status 分裂;模型照指令压必被闸门拒收) 已被另一 daemon 会话接手
    #3205(owner 立) 内核 buildCompressibleRanges 围绕 DEAD ref 切分 内核侧根治(Kernel Boundary) 分段机制本身不感知 DEAD,DEAD ref 落进已宣告 span 的内部 已被另一 daemon 会话接手

    为何不是重复(按 2026-10-13 粒度政策):三者同一根机制,但症状与产线都不同——「自我矛盾」(#3192)≠「跨面不一致 + 注定失败指令」(#3204)≠「分段机制缺陷」(#3205)。符合仓库既有「一条产线一条 issue」惯例(#2638/#2660 先例,#3204 正文亦引用此先例)。owner 拆分边界清晰、各带来源,无需并回。

    一个我核实过的技术边界(关系到 #3195 与 #3205 的分工,非转述):读了 kernel/src/compress.ts:177,提交闸门的 danglingMessageRefs 只校验两端点 [startRef, endRef],不查内部 ref。因此:

    范围确认:PR #3195 只动 4 个文件(src/acp-status.ts、src/stream.ts + 两个测试文件),没有碰 #3204 的两条产线(src/nudge-decide.ts、src/plugin.ts 面板字段、四个 prepare-* 决策分支)——不越界、不双重修复、不触发 loop-guard。

    建议合入顺序:#3195 先行(提供可复用 helper + 止血)→ #3204 复用该 helper 跟进 → #3205 内核根治收尾(需你批准立项后再实现)。三者合起来才是完整闭环,单看任何一个都不重复。

  5. ranxianglei commented on Oct 15, 2026

    @ranxianglei
    Owner

    #3205 我把这个拆分关闭,本issue处理

    为什么不默认覆盖区间?

    把 DEAD ref 当作分段间隙处理(与 covered/pruned/live-carrier/unrecoverable-media 同级的 skip+gap 判据):遇到 DEAD ref 就断开当前组、其后另起新组,输出相邻的存活子 span

  6. ranxianglei commented on Oct 15, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

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

    收到:#3205 由你关闭、并入本 issue;内核侧「围绕 DEAD ref 切分」在本 issue 处理。

    为什么我原来没「默认切分覆盖」、而是整段丢弃 —— 是层次限制,不是没想到:

    接下来我做(按你拍板的机制):

    1. 先核实一个前提:state.deadRefs 在 processTurn/buildCompressibleRanges 那个时间点是否已就位(它是在 compress 尝试里算的还是跨回合维护的?这决定分段处能不能直接读到它)——读透 kernel/src/recommend.ts + deadRefs 的产生点再动刀,不凭猜测改 load-bearing 代码。
    2. 内核侧改 buildCompressibleRanges:把 DEAD ref 提升为与 covered/pruned/live-carrier/unrecoverable-media 同级的 skip+gap 判据——命中即断组、其后另起新组,输出相邻存活子 span(默认覆盖,不再少报)。
    3. Kernel Boundary 全套照做:PR 声明 kernel-change:、bump kernel/package.json、双层测试(kernel 套件新增分段用例 + bili 回归测试改走修好的内核)、human-only review。
    4. 宿主侧 excludeDeadRefRanges 去留我给建议:内核不变量被测试钉死后,倾向移除(否则是死代码,违反整洁标准)还是保留为边界兜底,读完代码后定,并写进 PR。

    先读内核,动手前回报前提核实结果。

  7. ranxianglei commented on Oct 15, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

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

    按你说的做了——把 DEAD ref 当成分段间隙处理,遇到就断开当前组、其后另起新组,输出相邻的存活子 span。已实现并开 PR:#3230。

    先答你「为什么不默认覆盖区间」——这是层次问题:

    机制(我实测确认):客户端删掉一条消息后,它在数组里不留槽位,前后两条变数组相邻,于是 buildCompressibleRanges 分段、mergeRangesToThreshold、formatRanges 三处各自跨这个空洞桥接回一个罩住 DEAD ref 的大 span。修法=在 buildCompressibleRanges 里对 recorded-dead ref 断组(与 covered/pruned/carrier 同级判据),再给下一段打 noMergeBefore 标记,让两个合并器都不许跨洞并回去。state.deadRefs 为空时严格 no-op。

    八问

    1. 是什么问题:含 DEAD ref 的区间被整段丢弃时,DEAD ref 两侧仍能压的活消息被连带扣留、不列为可压缩;根因是删掉的消息不留数组槽位、各 range 层跨空洞桥接。
    2. 什么原因导致的:buildCompressibleRanges 从不读 state.deadRefs(gate 读、eligibility 不读)+ 删消息不留槽位导致跨洞桥接。fix: stop advertising DEAD refs as compressible in receipts and acp_status #3195/nudge 决策指令与 /acp 面板仍会列出含 DEAD ref 的压缩区间(#3192 同根机制的另外两条产线) #3204 用 host 整段丢弃补上了「矛盾现象」,但没解决「活消息被连带扣留」。
    3. 影响范围与严重程度:仅在「会话出现过被客户端删除/改写的消息、且该 ref 已被记为 DEAD」时触发;属效率/体验(可压内容被无谓扣留、多占上下文),非数据损坏、非崩溃。
    4. 怎么修复的:kernel 分段现场遇 DEAD ref 断组 + noMergeBefore 阻止两处合并器跨洞并回;host 的 excludeDeadRefRanges 保留为 no-op 兜底(nudge 决策指令与 /acp 面板仍会列出含 DEAD ref 的压缩区间(#3192 同根机制的另外两条产线) #3204 的 plugin/prepare-* 面还依赖它)。
    5. 是否有回归问题:covered/pruned/carrier 断组逻辑未动;deadRefs 空则严格 no-op;跑了所有会写 deadRefs 的测试文件(kernel 167 + bili 54 全绿,含 nudge 决策指令与 /acp 面板仍会列出含 DEAD ref 的压缩区间(#3192 同根机制的另外两条产线) #3204 面板测试);The compress failure receipt is self-contradictory: the same message first declares the ref permanently DEAD, then lists the range containing that DEAD ref as the "current compressible range." | compress 失败回执自相矛盾:同一条消息先宣告 ref 永久 DEAD,再把含该 DEAD ref 的区间列为「当前可压缩范围」 #3192 回归测试改为断言两个存活子 span 且都不罩 DEAD ref(旧版断言「continue the task」已失效,因为现在正确地列出了子 span)。
    6. 是否破坏缓存:不涉及——不改 wire 字节、不动前缀、不碰签名块。
    7. 是否改了设计方向:收敛到 kernel——由 range 产出方保证「不产罩 DEAD ref 的 span」,host 过滤退化为兜底,边界更干净、无新增旁路。
    8. 是否引入新配置:无。kernel acp-kernel 0.0.124→0.0.125(Kernel Boundary 强制 bump)。

    关系说明:#3205 按你的指示并入本 issue;本 PR 是已合入的 #3195 的 post-merge 跟进,在其之上做根治。kernel 变更走 human-only review,不自动合并。

    判定:定向验证全绿,待 CI 全局把关 + human review。PR: #3230

  8. ranxianglei commented on Oct 16, 2026

    @ranxianglei
    Owner

    冲突

  9. ranxianglei commented on Oct 16, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

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

    冲突已解决——rebase 到最新 master 并重新验证过。

    冲突点:只有 kernel/package.json 的版本号一行真正相撞(master 期间被别的 kernel PR 顶到了 0.0.126,我这边原来 bump 到 0.0.125)→ 解决为 0.0.127。另外两个文件是「改了但没撞」,git 自动合并干净、双方改动都保留:

    rebase 后 head 上重新跑过(不是沿用旧结果):kernel typecheck+build 干净、kernel 定向 167/167、bili typecheck 干净、bili 定向 56/56(含 #3192 回归 + #3204 面板测试)。确认 #3236 新增的 screenRecommendedUnits 和我的 dead-ref split 没有坏交互——它只会把「罩 DEAD ref 的 doomed unit」降级成 gap,而我的子 span 本来就不罩 DEAD ref,所以两边一致。

    当前状态:PR 已是 mergeable=true(不再是 conflict/dirty),只是 behind 了几个刚落地的无关提交(#3308/#3318 opencode-native 拒收超大 body,完全不碰我改的文件)。force-push 完成,PR head = bf574cec9。等 CI 全局把关 + human review。

    PR: #3230

  10. changed the title [-]compress 失败回执自相矛盾:同一条消息先宣告 ref 永久 DEAD,再把含该 DEAD ref 的区间列为「当前可压缩范围」[/-] [+]The compress failure receipt is self-contradictory: the same message first declares the ref permanently DEAD, then lists the range containing that DEAD ref as the "current compressible range." | compress 失败回执自相矛盾:同一条消息先宣告 ref 永久 DEAD,再把含该 DEAD ref 的区间列为「当前可压缩范围」[/+] on Oct 16, 2026
  11. added 2 commits that reference this issue on Oct 17, 2026
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