Repository navigation
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
Description
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 失败回执会在同一条消息内同时说两件互斥的事:
- 这些 ref 已被永久记为 DEAD,任何包含它们的区间永远压不了;
- 「当前可压缩范围」正是那个包含 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 层再拼一段文字:
- (首选,kernel)
buildCompressibleRanges()(kernel/src/recommend.ts)的跳过判据里加入state.deadRefs(按 ref 判断,与 gate 同源)。这样acp_status的Compressible ranges与失败回执 hint 会一起正确,不会再出现「status 说能压 / gate 说 DEAD」的分裂。 - (宿主侧规避) 在
liveCompressionRanges()/compressionRecovery()里对live.ranges做一次 dead 过滤;全部被滤掉时落到已有的" No eligible message ranges are available now; continue the task without compressing."分支。 - 恢复一行显式排除说明(旧
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)。
相关
- Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778(closed,PR Use live compression eligibility for recovery advice #2800 修复)—— protected / covered 那一半。本条是同一 PR 所承诺的 DEAD 那一半的回归。
- compress failure is self-amplifying: failed calls are hidden as orphan refs, making the same range permanently un-compressible #2362 / fix: dead-ref tombstones — stop the self-amplifying compress failure loop (#2362) #2370 —— dead-ref tombstone 机制。gate 侧是对的;本条是建议侧没跟上。
- kernel: when the session view is empty, compress still marks all request refs as DEAD (defense-in-depth hardening for dangling-ref detection on empty views) | kernel:会话视图为空时 compress 仍会把全部请求 ref 记成 DEAD(空视图判悬空的纵深加固) #3137 / kernel: empty view no longer marks requested refs DEAD (#3137) #3141 —— 空视图误判 DEAD 的纵深加固(dead 判定语义;与本文「建议侧不消费
deadRefs」是两件事)。 - [Bug][preflight] range selector re-nominates a fully-folded span every turn — permanent "no new compressible messages" rejection loop + nudge churn #2638 / [PR] fix(#2638): stop preflight re-nominating structurally-dead spans every turn #2660 —— preflight range selector 的同类「反复推荐不可压 span」(宿主侧);本条是失败回执这条独立产线。
Activity
ranxianglei commentedon Oct 14, 2026
(ai: vllm-qwen/qwen3.8-27b)
已定位并修复,PR:#3195 (base master)。分支已 rebase 到最新 master,本地定向测试全绿;全量回归交给 CI。
八问
是什么问题:一条 compress 失败回执自相矛盾——同一句话里既宣告某 ref「已记为 DEAD,任何包含它的区间现在和将来都压不了」,又把「当前可压缩范围」列成恰好罩住这个 DEAD ref 的区间(你例子里 m11615–m11620 含 m11620)。模型被迫多跑一轮 acp_status 才发现两处对不上。
什么原因导致的:两段独立计算没对齐。提交闸门(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 那条弄丢了。影响范围与严重程度:所有走 ACP compress 的插件/代理会话,当客户端改写或删掉某条消息(其 ref 变 DEAD)、且该 ref 落在某个可压缩区间内时触发。属体验缺陷而非数据损坏——不会压坏东西,但会把一个注定失败的区间再喂给模型一次,浪费一轮往返并制造困惑。严重度:中(特定条件触发)。
怎么修复的:在宿主侧加纯函数
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」停手指令,而不是列一个注定失败的区间。是否有回归问题:审过既有行为——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 变吞错、无阈值/时序/输出格式漂移——只是把闸门本就会拒绝的区间从清单里拿掉,不新增也不重排任何存活区间。
是否破坏缓存:不涉及。改动只在「对外展示哪些区间」这一层,不碰 prefix cache、快照游标、去重键或任何持久化格式。
是否改了设计方向:不改架构/边界/数据流,是把 Use live compression eligibility for recovery advice #2800 重构时弄丢的一处排除补回宿主侧。更根本的家在 kernel:让
buildCompressibleRanges自身围绕 DEAD ref 切分(能覆盖其它消费方,还能给出存活的子区间而非整段丢弃)——但那受 Kernel Boundary 约束(需 owner 批准 + 人工审核 + 版本 bump + kernel-change 声明)。宿主侧已完整解决用户可见问题,故不捆绑进本 PR,留作 owner-gated follow-up,此处先说明不擅自改 kernel。是否引入了新的配置:不涉及。无新 env/config/CLI 字段。
行为变更披露(旧→新):失败回执 / acp_status / nudge tail 此前可能列出含 DEAD ref 的区间 → 现在剔除这类区间(若因此清空则输出停手指令)。只移除闸门本就会拒绝的区间,绝不新增或重排存活区间。
合并判定:可合并。host-only、单模块、带行为断言的回归测试、rebase 后 typecheck + 定向测试全绿;全量以 CI 为准。CI 绿即可合。
ranxianglei commentedon Oct 14, 2026
是否和已有issue重复
ranxianglei commentedon Oct 14, 2026
[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,两者语义互补(一个管写、一个管读),顺序无依赖但文件有重叠。
后续接单查重结论必须作为第一条回复(修复开始前)——规则已补。
fix: stop advertising DEAD refs as compressible in receipts and acp_s…
ranxianglei commentedon Oct 14, 2026
(ai: vllm-qwen/qwen3.8-27b)
查重结论:不重复。 #3192 与既有的 #3204、#3205、#2778 都不重复——它们是同一根机制(资格视图
buildCompressibleRanges从不消费state.deadRefs)下按「产线 / 层次」刻意拆分的三个独立 issue,互补、无重叠。三者关系(owner 在 review 我的 PR #3195 后于 16:52Z 主动拆分,各带 来源 标记):
excludeDeadRefRanges整段剔除/acp面板字段buildCompressibleRanges围绕 DEAD ref 切分为何不是重复(按 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 内核根治收尾(需你批准立项后再实现)。三者合起来才是完整闭环,单看任何一个都不重复。
fix: also stop advertising DEAD-ref spans in the default prose nudge (#…
ranxianglei commentedon Oct 15, 2026
#3205 我把这个拆分关闭,本issue处理
为什么不默认覆盖区间?
把 DEAD ref 当作分段间隙处理(与 covered/pruned/live-carrier/unrecoverable-media 同级的 skip+gap 判据):遇到 DEAD ref 就断开当前组、其后另起新组,输出相邻的存活子 span
ranxianglei commentedon Oct 15, 2026
(ai: vllm-qwen/qwen3.8-27b)
收到:#3205 由你关闭、并入本 issue;内核侧「围绕 DEAD ref 切分」在本 issue 处理。
为什么我原来没「默认切分覆盖」、而是整段丢弃 —— 是层次限制,不是没想到:
src/acp-status.ts),拿到的只是buildCompressibleRanges已聚合好的 span({startRef, endRef, tokens/chars})。要拆出正确的存活子 span(如…–m00004/m00006–…),需要逐消息的 token/chars 口径——那份数据只在 recommend.ts 分段时算得出,宿主侧没有,硬拆只能猜边界和体量。所以宿主层能安全做的只有「整段丢弃」:保证绝不再宣告注定失败的 span(满足 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 验收),代价是内部洞场景系统性少报可压量。buildCompressibleRanges的分段处(逐消息统计在手),正是你说的 kernel: buildCompressibleRanges 应围绕 DEAD ref 切分区间,而不是让 DEAD ref 落进已宣告 span 的内部 #3205 机制。所以你的方向是对的,我只是当时受限于宿主层没法做对,选了次优但安全的止血。接下来我做(按你拍板的机制):
state.deadRefs在processTurn/buildCompressibleRanges那个时间点是否已就位(它是在 compress 尝试里算的还是跨回合维护的?这决定分段处能不能直接读到它)——读透kernel/src/recommend.ts+ deadRefs 的产生点再动刀,不凭猜测改 load-bearing 代码。buildCompressibleRanges:把 DEAD ref 提升为与 covered/pruned/live-carrier/unrecoverable-media 同级的 skip+gap 判据——命中即断组、其后另起新组,输出相邻存活子 span(默认覆盖,不再少报)。kernel-change:、bumpkernel/package.json、双层测试(kernel 套件新增分段用例 + bili 回归测试改走修好的内核)、human-only review。excludeDeadRefRanges去留我给建议:内核不变量被测试钉死后,倾向移除(否则是死代码,违反整洁标准)还是保留为边界兜底,读完代码后定,并写进 PR。先读内核,动手前回报前提核实结果。
ranxianglei commentedon Oct 15, 2026
(ai: vllm-qwen/qwen3.8-27b)
按你说的做了——把 DEAD ref 当成分段间隙处理,遇到就断开当前组、其后另起新组,输出相邻的存活子 span。已实现并开 PR:#3230。
先答你「为什么不默认覆盖区间」——这是层次问题:
{startRef,endRef}span,没有逐条消息的 token 账本,没法自己切出正确的子 span。它唯一能做的就是「整段丢」(fix: stop advertising DEAD refs as compressible in receipts and acp_status #3195/nudge 决策指令与 /acp 面板仍会列出含 DEAD ref 的压缩区间(#3192 同根机制的另外两条产线) #3204 已经这么做了,自相矛盾的现象在 master 上已消失),代价是把 DEAD ref 两侧还活着的消息也一起扣住。buildCompressibleRanges的分段现场——那里手里有逐条统计。所以根因只能落 kernel,这也正是你给的方向。机制(我实测确认):客户端删掉一条消息后,它在数组里不留槽位,前后两条变数组相邻,于是
buildCompressibleRanges分段、mergeRangesToThreshold、formatRanges三处各自跨这个空洞桥接回一个罩住 DEAD ref 的大 span。修法=在buildCompressibleRanges里对 recorded-dead ref 断组(与 covered/pruned/carrier 同级判据),再给下一段打noMergeBefore标记,让两个合并器都不许跨洞并回去。state.deadRefs为空时严格 no-op。八问
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 整段丢弃补上了「矛盾现象」,但没解决「活消息被连带扣留」。noMergeBefore阻止两处合并器跨洞并回;host 的excludeDeadRefRanges保留为 no-op 兜底(nudge 决策指令与 /acp 面板仍会列出含 DEAD ref 的压缩区间(#3192 同根机制的另外两条产线) #3204 的 plugin/prepare-* 面还依赖它)。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)。acp-kernel0.0.124→0.0.125(Kernel Boundary 强制 bump)。关系说明:#3205 按你的指示并入本 issue;本 PR 是已合入的 #3195 的 post-merge 跟进,在其之上做根治。kernel 变更走 human-only review,不自动合并。
判定:定向验证全绿,待 CI 全局把关 + human review。PR: #3230
ranxianglei commentedon Oct 16, 2026
冲突
kernel: break range groups at dead-ref holes and emit adjacent live s…
ranxianglei commentedon Oct 16, 2026
(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 自动合并干净、双方改动都保留:kernel/src/recommend.ts:master 追加了 [Bug] recommend/apply 对同一区间的 turn-integrity 判定永久不一致:acp_status 反复推荐的区间被 apply 侧整段拒绝(0.1.196,Range would split N turn(s) at the protected-zone boundary) #3236 的screenRecommendedUnits(文件尾部新函数 + 顶部两个 import),和我改的中段(dead-ref 断组 / merge 判据)不同区域;kernel/src/types.ts:master 删掉了 image-compression 相关字段(image_full 无法被正确调用:同一张图每轮重复降采样(38 次)、restore 提示注入 38 次,模型只能猜 ref → 每轮一次失败+重发,缓存命中从 75% 掉到 28% #3266/feat!: remove image pre-compression and the image_full tool (#3266) #3295),和我在CompressibleRange/ProtectedRange加noMergeBefore的位置不重叠。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
[-]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 的区间列为「当前可压缩范围」[/+]kernel: break range groups at dead-ref holes and emit adjacent live s…
Merge pull request #3230 from ranxianglei/2026-10-15_fix-3192-dead-re…
kernel: filter dead refs out of the per-turn statusLine offer (#6661)