Repository navigation
[PR] fix: #4224 emergency digest quality + convergence (multi-fold, dynamic trim, structural conclusion) - #4226
ranxianglei wants to merge 2 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.5020-pr.4226.235f0b4This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4226.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…c trim, structural conclusion) Three defects in the #2387 deterministic-digest emergency path, all confirmed against v0.1.201/0.1.202 production evidence (dsh fork, deepseek-flash, 87 blocks at 22.9% window): 1. One fold per round → 87 requests to converge. The serial walk inherited the LLM-path 'one fold per round' cap, but emergency digests are CPU-only (zero upstream calls). Now the full walk drains in a single round when emergencyFold is active. Non-emergency path unchanged (maxFoldsPerRound=1). 2. fits() all-or-nothing head trimming → ≥132-entry spans lose ALL excerpts. Instead of [120→0→header-only], compute the per-line head budget from remaining space so large spans keep short excerpts (floor 24 chars). 3. Zero-conclusion digest → model sees an index, not a summary. Added a one-line structural conclusion (counts by message category: bash×89, read×45, etc.) so even when per-entry excerpts are trimmed, the digest conveys WHAT happened in the span. Tests: updated existing fallback test for the new structure line; added dynamic-trim regression test (150 entries keep excerpts below 120 chars); added extreme-bounds header-only fallback test.
…one verb
Review finding on the original commit: digestLabelCategory matched
label.startsWith("tool-result"), but the digest entry builders emit
'tool result <verb>' (space-separated), so that branch was dead code and
tool-heavy spans (the #4224 corpus is ~100% tool traffic) got one category
per 'tool result bash' instead of merging with its call. Both forms now
collapse to the verb: Structure: 178×bash for 89 calls + 89 results.
b81a9c2 to
91b2da9
Compare
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 本 PR 是 #4224 的实现 PR;#4224 与 #2383 不重复(#2383 = 极端溢出时根本没有快速路径,新增 deterministic digest 路径;#4224/#4226 = 该快速路径自身的三个质量/收敛缺陷)。按失败签名检索 open+closed,无其他触及同一机制的在途 issue/PR。 标签: bug dsh scope/kernel p1(缺陷类;生产证据来自 dsh 车道;领域 = src 侧压缩决策面;严重程度沿用原 issue triage —— 排空前会话不可用 + 块只增不减失控类)。 审核结论:可合并(待新 head 的主 CI 转绿)。 我在 PR 分支上推了 2 个 commit:
本地定向验证(rebase 后 head):typecheck clean、build OK、 结构化八问
行为变更披露(旧值 → 新值 + 原因)
非紧急路径:零行为变化。 遗留问题(不阻塞合并)PR 正文已列的两个 known remaining issues 已转为可跟踪工作项 #4228(单一 issue 汇总两个同失败面子缺陷,带来源标记,标签 bug/scope/wiring/p3):①多活跃块下 shrink%/postCtx 日志记账少算节省量;②preflight 与 compress 工具层耗尽消息互相矛盾。两者均为既有缺陷(先于本 PR),多折叠使其更易暴露,修复不阻塞本 PR。 判定可合并(等 |
Two diagnostic sub-defects from the #4226 multi-fold world, one failure domain (the observation layer still assumed "one fold per round"): SD1 — [acp-compress-obs] shrink%/postCtx undercounted savings. Preflight's commitFold calls applyRanges once per range against the SAME stale ctx.messages, so each line subtracted only its own fold from the full request view (#4224: "shrink 0% ... postCtx≈14.5M"). Preflight now hands applyRanges its running currentTokens as roundBefore; the obs nets this fold against it so each line reports the live remainder. The model-tool lane (no roundBefore) keeps the #1911 same-space gross-over-view formula byte-identical. Token scale only — unknown- baseline (char) sessions skip the baseline to avoid mixing scales. The corrected V/Vp also feed the cache ledger (reporting surface only). SD2 — the drained-offer stop signal asserted "the context is already at its minimum", a global claim backed only by the prepare-time offer being exhausted (#2404 pins it to the pre-fold offer, never a live recompute), so it contradicted preflight's fresh viable-range count. Narrowed the wording to the local fact it actually verifies; preflight still auto-compresses overflow. Behavior changes (disclosed): - preflight multi-fold [acp-compress-obs] lines now report running-baseline values tagged "(round)" instead of the stale full view (denominator was the full request view, now the running payload; postCtx now nets the re-entering summary). Single-call lanes unchanged. - cache-ledger fold geometry V/Vp now use the running baseline in multi-fold rounds (was the stale full view) — reporting-only, no cache decision impact. - model-facing stop-signal text changed (SD2); all lanes share stream.ts, so proxy/plugin stay consistent. Regression tests: tests/compress-success-tail.test.ts (+3).
Two diagnostic sub-defects from the #4226 multi-fold world, one failure domain (the observation layer still assumed "one fold per round"): SD1 — [acp-compress-obs] shrink%/postCtx undercounted savings. Preflight's commitFold calls applyRanges once per range against the SAME stale ctx.messages, so each line subtracted only its own fold from the full request view (#4224: "shrink 0% ... postCtx≈14.5M"). Preflight now hands applyRanges its running currentTokens as roundBefore; the obs nets this fold against it so each line reports the live remainder. The model-tool lane (no roundBefore) keeps the #1911 same-space gross-over-view formula byte-identical. Token scale only — unknown- baseline (char) sessions skip the baseline to avoid mixing scales. The corrected V/Vp also feed the cache ledger (reporting surface only). SD2 — the drained-offer stop signal asserted "the context is already at its minimum", a global claim backed only by the prepare-time offer being exhausted (#2404 pins it to the pre-fold offer, never a live recompute), so it contradicted preflight's fresh viable-range count. Narrowed the wording to the local fact it actually verifies; preflight still auto-compresses overflow. Behavior changes (disclosed): - preflight multi-fold [acp-compress-obs] lines now report running-baseline values tagged "(round)" instead of the stale full view (denominator was the full request view, now the running payload; postCtx now nets the re-entering summary). Single-call lanes unchanged. - cache-ledger fold geometry V/Vp now use the running baseline in multi-fold rounds (was the stale full view) — reporting-only, no cache decision impact. - model-facing stop-signal text changed (SD2); all lanes share stream.ts, so proxy/plugin stay consistent. Regression tests: tests/compress-success-tail.test.ts (+3).
What
Three defects in the #2387 deterministic-digest emergency path, confirmed against v0.1.201/0.1.202 production evidence (dsh fork, deepseek-flash v4.1, 87 blocks at 22.9% window):
appliedThisRound===0cap; wasteful for CPU-only digestsmaxFoldsPerRound = InfinitywhenemergencyFold; full walk drains in one roundfits()tries [120→0→header-only] all-or-nothing(maxSummary - baseLen - 4N)/N, floor 24 charsStructure: 89×bash, 45×read, 22×write, ...Behavior changes
entryOvershoot > 19.2x): folds multiple ranges per round instead of one. Non-emergency path unchanged.Structure:line between header and per-entry lines. Degrades gracefully (dropped before header at extreme bounds).Known remaining issues (follow-up)
shrink%/postCtxlog values misleading with many active blocks (only subtracts current fold's savings)Tests
Closes #4224