Skip to content

[PR] fix: add recovery guidance to the dsh compaction refusal message (#3499) - #3502

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-17_issue3499-compact-refusal-guidance
Oct 20, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-17_issue3499-compact-refusal-guidance

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #3499

What this changes

On a bili-native dsh lane, /compact (any dsh compaction call) is refused by design (#1729: a landed dsh checkpoint durably shadows the raw history and destroys bili's compression substrate). The refusal message explained only WHY it is refused and HOW TO FORCE dsh compaction (allowDshCompaction) — never what to do INSTEAD.

In incident #3450 an over-window session left the user with no visible in-band recovery lever: two manual /compact attempts (19:57:10, 19:58:25) were refused locally (60 ms, no upstream traffic, nothing billed), each surfacing "Compaction could not produce a useful summary" plus an opt-in hint that pointed the wrong way for that state. Disabling the plugin became the only remaining option.

This PR adds the recovery sentence and repositions the opt-in as a last resort:

Before:

…destroys the proxy's compression substrate. To run dsh native compaction on this lane anyway, opt in explicitly: "allowDshCompaction": true in the bili config or env BILI_ALLOW_DSH_COMPACTION=1 (#2028).

After:

…destroys the proxy's compression substrate. No action is needed: your conversation is intact and bili compresses automatically as turns grow too large — if the session is currently over its window, it starts folding on the next turn (#3453). If you still want dsh native compaction on this lane, opt in explicitly: "allowDshCompaction": true in the bili config or env BILI_ALLOW_DSH_COMPACTION=1 (#2028).

Behavior change disclosure

Verification

  • Extended the existing refusal-body test to pin the guidance sentences (tests/dsh-compaction-guard.test.ts).
  • Targeted suites green 35/35 (dsh-compaction-guard, issue2028-dsh-compaction-toggle, issue2709-passthrough-compaction-guard, issue2658-dsh-anthropic-google-compaction); typecheck clean. Full-suite verdict = CI on the pushed head.

Scope notes

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-17_issue3499-compact-refusal-guidance (8b0bf92)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4648-pr.3502.2b11dcc

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3502.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 按失败签名("compaction refusal guidance"、"No action is needed")检索 open+closed issues/PR,命中项只有本 PR 自身;相关条目 #1729(guard 原始设计)、#2028(opt-in 开关)、#3450(事故)、#3499(本 issue)均未修过这个文案缺口。

① 原 issue(方向关):#3499 按报告者 DSH journal 重定范围后,剩余缺陷 = dsh compaction 拒绝消息只讲「为什么拒 + 怎么强制」,从不说「那该做什么」;#3450 事故里 over-window 会话的用户因此没有带内恢复杠杆,唯一可操作的一行还指向有害选项。本 PR 在源头(用户可见字符串常量 REFUSAL_MESSAGE)修这个缺口——方向正确,修的是根因不是症状。

② 回归审查(diff 触碰路径的既有行为清点,逐项结论):

  • 拒绝决策逻辑(isDshCompactionCall / dshCompactionRefusal):未动 ✅
  • 422 status / retryable:false / code dsh_compaction_refused / openai 与 anthropic 两种协议形状:未动 ✅(测试钉住)
  • 配置面:无 key 增删改名,allowDshCompaction / BILI_ALLOW_DSH_COMPACTION 语义未动 ✅
  • wire 形状:body 结构未动,仅 message 文本变化——有意变更,PR 描述已披露旧→新全文 ✅
  • 旧文案的其他副本:全仓 grep 只有这一个常量,无第二处需要同步 ✅
  • 既有测试断言(/#1729/、/durably/、code/retryable)全部保留,只增不删 ✅

③ 代码:一个字符串常量 + 一条注释 + 两条断言。关键核实:新句「if the session is currently over its window, it starts folding on the next turn (#3453)」与 #3453 的实际机制吻合——我逐行读了 #3453 的 patch:上游 stated overflow 计数被记入 fold target(lastInputTokens 记账 M、wall 变 window−K),下一请求 preflight 即折叠。句子成立。

④ 测试有效性:两条新断言钉住引导句的确切措辞(No action is needed / starts folding on the next turn),措辞回归会被抓到——有牙,非恒真。refusal 契约(status/retryable/code)由同测试内既有的断言继续兜底。

⑤/⑤b diff 与代码整洁:2 文件 +7/-1,每一行都与本 PR 目的相关;注释风格与仓库一致(说明 why、引用 issue 号);无死代码、无魔法串。全项通过。

⚠️ 合并顺序(必须遵守):新句子描述的是 #3453 的行为,而 #3453 目前仍 open 未合。本 PR 先于 #3453 进 master 会存在「句子先行、行为未落地」的窗口期。两 PR 零文件重叠(已核对 #3453 触碰的 12 个文件与本 PR 的 2 个文件无交集),rebase 成本为零——请先合 #3453 再合本 PR(或同一 release 一起发)。PR 分支当前 behind master,但无文件冲突,顺序满足即可直接合。

验证证据:

  • 本地定向(PR head 内容落在 merge-base 上实测):4 个套件 35/35 全过(dsh-compaction-guard / issue2028-dsh-compaction-toggle / issue2709-passthrough-compaction-guard / issue2658-dsh-anthropic-google-compaction);typecheck clean。
  • 远程 CI(head 38241e47):6 个 test shard(ubuntu/windows × node22/24 × 3 shard)全绿;static-gates、gate、docs-sync、lane-guard、version-guard、plan、pi-subagents-guard、unused-exports、test-import-graph 全绿。

结构化八问

  1. 是什么问题:bili-native dsh 车道上 /compact 被设计性拒绝,但拒绝消息只说为什么拒、怎么强制,不说替代做法;over-window 时用户没有带内恢复杠杆,最后只能禁用插件。
  2. 什么原因导致的:拒绝消息历史上写成「禁止解释 + 如何绕过禁止」,正常路径(bili 自动压缩、无需操作)从未写进消息,over-window 场景下唯一可执行的一行指向有害的 opt-in。
  3. 影响范围与严重程度:所有触发 compaction 拒绝的 bili-native dsh 车道(三种协议形状共用同一常量)。本地 422 拒绝、无计费、会话无损——属体验瑕疵/死胡同错误,非功能损坏。
  4. 怎么修复的:在唯一拒绝字符串常量里补一句恢复指引(无需操作、会话完好、bili 随轮次自动压缩、over-window 时下一轮开始折叠),并把 opt-in 提示从「做法」降级为「如果你仍然想要」。
  5. 是否有回归问题:无。决策逻辑、状态码、retryable、错误码、配置面、wire 结构均未动;唯一有意变更是用户可见文案本身,已在 PR 描述披露旧→新。
  6. 是否破坏缓存:不涉及(纯错误文案,不触碰任何缓存/重试/游标/去重策略)。
  7. 是否改了设计方向:否。
  8. 是否引入新配置:否。

判定:可合 —— 前提是先合 #3453(或同一 release 一起发);顺序满足后无其他阻塞。

@ranxianglei
ranxianglei merged commit 0eb6b2e into master Oct 20, 2026
22 checks passed
@ranxianglei ranxianglei changed the title fix: add recovery guidance to the dsh compaction refusal message (#3499) [PR] fix: add recovery guidance to the dsh compaction refusal message (#3499) Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.646-master.0eb6b2e (rolling master tag).

npm install -g billion-context@0.0.646-master.0eb6b2e  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant