Repository navigation
fix(#3384): gate the #2490 refused-ledger planning floor so healthy dsh sessions keep their output budget - #3391
Conversation
…sh sessions keep their output budget
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4117-pr.3391.0baf062This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3391.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 本 PR 是 #3384 的修复本身(非并列工作)。相关条目均为互补机制而非重复:#2490(拒绝账本 floor 的出处 + giant-request 保护区间)、#3071(4096 能力底)、#3045(拒绝终局可见性,独立 PR 无重叠)。方向关通过——修的是「floor 无条件应用」这个根因,不是治标。 我独立核对了 diff、调用方、测试与合并状态(未照抄 #3384 线程结论;本地未跑全量,以 CI 为准)。 独立核验要点
八问
判定:可合并。 根因修复到位、两条保护区间均有测试钉住、diff 干净(单 commit / 5 文件全部相关)、CI 全绿、对当前 master 干净合并。合并由人来执行:#3391 。第 5 问的可选项(giant 线随配置派生)若要做建议另开 issue 讨论,不阻塞本 PR。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.516-master.9c56a54 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3384
What was wrong
Since #2490,
clampOutgoingOutputplans the outgoing output budget againstmax(folded-view input, refused-dsh-compaction ledger floor), where the floor is the byte size of the last REFUSED dsh compaction replay / 4. The floor was applied unconditionally.But the refusal guard (#1729/#2360) refuses by default, and a refused checkpoint never lands in the client's history — so the client's raw ledger only grows while bili's own folds keep the wire payload small. The floor therefore rises every turn against a wire that stays small, and the clamp deterministically starves the model's output budget:
Reported incident (bili 0.1.197, DSH desktop, 1M window, onlyReasoning model):
Folded wire sat at ~9% of the window while the ledger floor reserved ~95%. The clamped 5909-token budget was eaten entirely by thinking (
canDisableThinking: false) → upstreamstopReason: length→ no text, no tool-call → empty GUI turns, every step from turn 8 on. The #3071 4096 capability floor cannot save this regime: 5909 > 4096, and any fixed floor is whack-a-mole against a monotonically rising ledger.The fix
The floor exists for ONE threat: a giant requested output riding a small folded view out the door while the client's raw ledger hugs the wall (#2490: requested 384K = 38.4% of the window, folded 20%, ledger 90% → one 7.5MB assistant turn → un-fold kill chain). Gate its application on the two independent grounds under which that threat actually exists — either suffices:
inputEstimate >= headroomWindow);OUTPUT_LEDGER_FLOOR_GIANT_REQUEST_PCT, aligned with the output headroom 目前仍按 max_tokens 全额预留,是否应改为最大输出的 1/4 / 支持配置比例? #896 defaultoutputHeadroomMaxPctand the clampOutgoingOutput sizes max_tokens against the raw native window while preflight enforces the reserve-adjusted one — up to 25% of slack the clamp never sees #2096 comment line "when max_tokens > 25% of the window the overflow boundary lies BELOW the headroom target").A modest request cannot push a near-wall ledger over in one turn, so planning against the ledger in that case buys nothing but starvation. When neither ground holds, planning uses the folded view alone — which is what actually goes out the door.
Behavior change (old -> new)
max(folded view, refused-ledger floor)— even when the folded view was 8% of the window and the request modest.clamped 50670 -> 5909/ new: no clamp, full 50670 rides out. In the dsh压缩与bili压缩冲突 #2490 incident shape (requested 384K vs 1M window): unchanged, still clamps 384K -> 55K.dshCompactionRefusedBytes) is untouched — only its APPLICATION is gated.Tests
tests/issue3384-ledger-floor-starvation.test.ts: unit truth table (incident shape unclamped [red pre-fix], giant-request arm still clamped to 5909, inclusive 25% boundary, below-line unclamped, view-at-enforced-target arm engaged, legacy paths byte-identical) + e2e throughstartServer(refused 350KB envelope records the floor, then a 20K-budget turn goes out UNCLAMPED — pre-fix it went out at ~8056).tests/issue3148-upstream-circuit.test.ts: the pinned clamp-event case now requests 300_000 (>= 25% of its 1M window) so the hook path it pins stays covered; its OLD 65_536 case is kept as a second assertion that pins the dsh native compaction guard refuses 100% → client ledger never shrinks → every step fails from turn 8, last 4 turns output empty | dsh 原生压缩守卫 100% 拒绝 → 客户端本地账本只增不减 → 会话第 8 轮起每步失败、后 4 轮输出全空 #3384 regression (modest request, huge ledger -> NO clamp event, budget untouched).Out of scope (deliberate): the reporter's suggestion to ALLOW one rebased dsh-native compaction after N refusals — that contradicts the owner ruling recorded in #3016 (order-first: anything breaking bili's fold order should be refused); raised as a decision item in the issue thread instead. Refusal-terminal visibility (bili_final marker + storm logging) is open PR #3045 — complementary, no overlap.