Repository navigation
[PR] fix: only a substantial fold disarms the compress-loop breaker (root-cause: compress-gate — #7197 + #7300) - #7326
ranxianglei wants to merge 2 commits into
Conversation
…mpress breaker (#7197)⚠️ MODEL-FACING TEXT CHANGE: scope-gate refusal receipts no longer carry the 'COMPRESS CIRCUIT BREAKER: ARMED — STOP calling compress now: do not try other ranges, do not re-issue any previous range, and do not poll acp_status.' paragraph. The core refusal wording is unchanged. The model now sees the refusal + advice ('Call acp_status ... stay within them') and follows it with an in-recommendation retry — the recovery the removed paragraph forbade. No number/ref/position the model propagates moves. The out-of-recommendation scope gate is a range-correctness gate ('your span was wrong'), not a fold-feasibility signal. Its recovery (acp_status -> an in-recommendation retry) is always available and succeeds if followed, so arming the session-level breaker (which orders 'do not try other ranges ... do not poll acp_status') forbade the only recovery the code still allowed: an obedient model lost compression for the whole session while a disobedient one recovered on the next call. Remove noteCompressLoopFailure from the scope-gate branch; keep recordCompressFailure so the #6728 repeat-collapse still fires on identical re-submission. The nudge gate keeps the breaker charge (its recovery is 'wait for a nudge' - no self-recovery). Update tests/issue6728-policy-gate-ledger.test.ts: the requireRecommendation test now asserts the breaker stays disarmed and the repeat-collapse still fires. (cherry picked from commit 97c4a1e)
…stantial fold/success (a trivial one that saves almost nothing does not count)" instead of "one successful fold/success" — the armed receipt, the substrate-destruction paragraph, and the acp_status armed note all moved from "any success disarms" to "a success that saves ≥500 tokens disarms". fix: only a substantial fold discharges the compress-loop breaker (#7300) The breaker streak (compressFailStreak) reset on ANY successful compress, so the incident's "fail×N → trivial-success×1 → fail×N" loop (bili 0.1.216: 398 compress calls, 289 "too small" fails, 92 trivial successes netting only 86–290 tokens) never armed the 3-strike breaker and the model burned tokens probing forever. r.tokensCompressed is the TOTAL folded mass (the kernel sums the folded message tokens and never subtracts the new summary), so a barely-over-minimum range reads ~1250 even when the NET saving is 86–290 tokens. Discharge the streak only when the NET saving (folded mass minus the new summary mass of the block(s) this fold created/updated) is ≥ COMPRESS_LOOP_DISCHARGE_MIN_TOKENS (500): a trivial fold is the model still probing, not "compression is working". Tests: tests/issue7300-compress-loop-trivial.test.ts pins both directions (trivial success does NOT discharge; substantial success DOES). Updated the three existing assertions that quoted the old disarm wording.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.11004-pr.7326.22e3f77This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7326.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Dup check: not a duplicate — related to #7209 (the single-issue #7197 PR): this PR cherry-picks #7209's exact commit (verified: same patch, Live state (verified just now): PR open, mergeable, What I verified independently:
Behavior changes (disclosed per policy, old → new + why):
八问(中文,供审核):
判定:可合。 合并后请关闭被取代的 #7209(我按政策不能关)。 |
Root cause (compress-gate)
Two open issues share one root cause — the compress circuit breaker (compressFailStreak) does not arm when it should:
Fix
[Bug][dsh] Circuit breaker armed by compress.requireRecommendation range misses: receipt forbids the only recovery the code still allows | 范围猜错三次即武装熔断,而熔断文案禁止了代码仍允许的自救动作 #7197 (cherry-picked from PR [PR] fix: scope-gate (requireRecommendation) refusals no longer arm the compress breaker (#7197) #7209, authorship preserved with -x): the scope gate now charges only the spec-repeat ledger (recordCompressFailure), never the session breaker (noteCompressLoopFailure). The scope gate is a range-correctness gate, not a fold-feasibility signal; its recovery is always available, so arming the breaker would forbid it.
billion-context 0.1.216 — compress no-op: symptoms, root cause, and proposed patch | billion-context 0.1.216 — compress 空转:现象、根因、可提的补丁 #7300: a success discharges the streak only when it is a SUBSTANTIAL fold. r.tokensCompressed is the TOTAL folded mass (the kernel sums the folded message tokens and never subtracts the new summary), so a barely-over-minimum range reads ~1250 even when the NET saving is 86–290 tokens. The streak now discharges only when the NET saving (folded mass minus the new summary mass of the block(s) this fold created/updated) is ≥ COMPRESS_LOOP_DISCHARGE_MIN_TOKENS (500). A trivial fold is the model still probing, not "compression is working".
Tests
Supersedes PR #7209
This PR cherry-picks PR #7209's exact commit (the #7197 fix) and adds the #7300 fix. It is the single root-cause PR for the compress-gate batch. PR #7209 (the single-issue #7197 PR) is now redundant and can be closed once this merges.
Fixes #7197
Fixes #7300