Skip to content

[PR] fix: wire external-summary all-fail batches into the compress circuit breaker - #6924

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-16_6903-ext-summary-breaker
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-16_6903-ext-summary-breaker

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

⚠️ MODEL-FACING TEXT CHANGE: the external-summary all-failure receipt now appends the compress-loop pause paragraph once the breaker arms (n≥3), and a new pre-dispatch armed-refusal receipt is returned when the breaker is already armed by external-summary failures. Both are model-visible instruction/state text.

Consumption-chain regression inference (§7.3, mandatory for model-facing text):

  • The pause paragraph (loopNoisePauseParagraph) is the EXISTING verbatim wording (owner decision 2026-10-07) — no new numbers/refs the model could anchor on.
  • The new armed-refusal receipt states n and decayMinutes — both REAL values from the streak (no phantom values). It carries no message refs, no token counts, no positions.
  • The model's next action after seeing either text is to STOP calling compress and continue the task — there is no number to copy into a subsequent call.

What this fixes

The external-summary all-failure branch in applyConfiguredCompression() (src/external-summary-compress.ts) returned directly without entering the consecutive-failure breaker, so repeated compress calls kept re-requesting unavailable candidates and the existing 3-failure / 10-min cooldown protection never stopped the session.

Repro (no real provider): configure two local summary endpoints returning HTTP 403, call compress three times on the same compressible range → 6 endpoint requests; the 4th call was still dispatching. After this fix the 4th call is refused before dispatch.

How

  • Count dispatched-but-all-failed batches in the existing breaker (3-failure threshold, 10-min cooldown). Count only when a candidate call was actually dispatched (plan.stats.attempts > 0) and the batch is finished/deadline — a congestion-only batch (no dispatch) and a cancelled batch (request teardown) are NOT provider failures.
  • Refuse BEFORE dispatch when the breaker is armed by the external-summary cause. Cause-gated (not any-armed) so substrate-destruction's instructed recovery (compress one live range) and stale-ref re-anchoring can still dispatch and clear the breaker. The gate does not call noteCompressLoopFailure, so repeated refusals do not extend the 10-min cooldown.
  • Recovery: one successful fold clears the streak (existing applyRanges behavior); the 10-min decay allows a recovery probe.
  • The forced cause (external-summary-failure — …) keeps the provider-down verdict visible to acp_status without claiming summary-too-long (the underlying provider cause stays an independent diagnosis, per the issue).

Regression tests (new file tests/issue6903-external-summary-breaker.test.ts)

  1. all-fail batches arm the breaker; the 4th call is refused before dispatch (no new requests, no cooldown extension)
  2. congestion-only batch (no dispatch) does not arm the breaker
  3. decay + success clears the breaker
  4. decay recovery: a decayed breaker dispatches again and restarts the count at 1

All 4 pass; the related existing suites (issue2146, issue4812, issue3126, issue3635, external-summary-runtime, agent-providers, wire-contract-go-session) all pass.

Config surface

None new — reuses the existing breaker mechanism (threshold / cooldown / cause).

Closes #6903

… breaker

⚠️ MODEL-FACING TEXT CHANGE: the external-summary all-failure receipt now
appends the compress-loop pause paragraph once the breaker arms (n>=3), and a
new pre-dispatch armed-refusal receipt is returned when the breaker is already
armed by external-summary failures. Both are model-visible instruction/state
text. Consumption chain: neither text introduces a new number/ref/position the
model could anchor on — n and decayMinutes are real streak values, and the
pause paragraph is the existing verbatim wording (owner decision 2026-10-07).
The model's next action after either text is to stop compressing, not to copy a
value into a subsequent call.

The external-summary all-failure branch (applyConfiguredCompression) returned
directly without entering the consecutive-failure breaker, so repeated compress
calls kept re-requesting unavailable candidates and the 3-failure / 10-min
cooldown protection never stopped the session.

- Count dispatched-but-all-failed batches in the existing breaker (3-failure
  threshold, 10-min cooldown). Count only when a candidate call was actually
  dispatched (plan.stats.attempts > 0) and the batch is finished/deadline —
  a congestion-only batch (no dispatch) and a cancelled batch (teardown) are
  not provider failures.
- Refuse BEFORE dispatch when the breaker is armed by the external-summary
  cause. Cause-gated (not any-armed) so substrate-destruction's instructed
  recovery and stale-ref re-anchoring can still dispatch and clear the
  breaker. The gate does not call noteCompressLoopFailure, so repeated
  refusals do not extend the 10-min cooldown.
- One successful fold clears the streak (existing applyRanges behavior).
- The forced cause keeps the provider-down verdict visible to acp_status
  without claiming summary-too-long (the underlying provider cause stays an
  independent diagnosis).

Config surface: none new (reuses the existing breaker mechanism).
Closes #6903
@ranxianglei ranxianglei changed the title fix: wire external-summary all-fail batches into the compress circuit breaker [PR] fix: wire external-summary all-fail batches into the compress circuit breaker Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-16_6903-ext-summary-breaker (6bbfdcc)

Latest build — install this exact version

npm install -g billion-context@0.0.10365-pr.6924.73fbeaa

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

Recent builds (commit → version)

commit version build
6bbfdcc billion-context@0.0.10365-pr.6924.73fbeaa build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6924.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: opencode/qwen3.8-27b)

🔶 需要决策

查重: duplicate — PR #6905 targets the same thread #6903. PR #6905 ("fix(external-summary): stop repeated total failures and recover after repair", created 2026-11-16 08:38Z — 51 minutes BEFORE this PR's 09:29Z) also Fixes #6903, with the same symptom (external-summary all-failure batches bypass the 3-failure/10-min breaker, repeated compress keeps dispatching to dead endpoints), the same root cause (the all-fail branch of applyConfiguredCompression returns without touching compressFailStreak), and the same fix family (wire all-fail batches into the existing breaker + refuse before dispatch). Per the one-PR-per-thread rule, this later PR should not exist — its work belongs on #6905's branch.

背景一句话: two open PRs fix issue #6903 (all external-summary candidates failing never arms the consecutive-failure breaker, so repeated compress calls keep re-requesting unavailable candidates).

待决问题: which PR to keep.

选项:

不决定的默认行为: I cannot close either PR (owner-only). Both stay open and will step on each other at merge time; I recommend closing #6924.

Independent review of this PR (done regardless of the dedup verdict — full diff read, every referenced symbol verified against the branch):

Verified against the code:

  • compressBreakerDetail (src/stream.ts:346) returns {n, threshold, decayMinutes, cause?} only while n≥3 AND within the 10-min window — the gate condition is correct.
  • noteCompressLoopFailure (src/stream.ts:309) returns "" for n<3 and the verbatim loop-noise pause paragraph for n≥3, with forcedCause winning — so the n=3 arming receipt gets the existing paragraph, as claimed.
  • compressResult(text, outcome, blocksCreated, reason?) — the 4th arg exists; gate:external-summary-breaker matches the existing gate:* convention.
  • plan.stats.attempts (src/external-summary-runtime.ts:26) counts dispatched candidate calls; batch.status ∈ finished|cancelled|deadline — so providerFailure = attempts > 0 && (finished || deadline) correctly excludes congestion-only and cancelled batches.
  • Success clearing: the applyRanges success path calls clearCompressLoopStreak (src/stream.ts:1627) — full and partial success both clear the streak.
  • The pre-dispatch gate does not call noteCompressLoopFailure — repeated refusals do not extend the cooldown (test 1 asserts lastAt unchanged).
  • No kernel change, no version bump, no config surface, no lockfile churn; 3 files, clean diff.

Test gaps (must be fixed if option B is chosen):

  1. The cause gate ships without its negative direction (Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 gate discipline: every gate asserts both "triggers when it should" AND "does NOT trigger when it should not"). No test verifies that a breaker armed by a NON-external-summary cause (e.g. substrate-destruction) still lets external-summary dispatch through — yet cause-gating is this PR's core design argument.
  2. The n=3 arming-receipt claim is unasserted: the PR body says the all-failure receipt "now appends the compress-loop pause paragraph once the breaker arms (n≥3)", but test 1 discards the 3rd call's result inside the loop (only outcome is asserted); the variable named third is actually the 4th call.
  3. (Behavior, not a test) No config-repair recovery — see option B cost.

CI (live-verified 2026-11-16 ~09:40Z): this PR's run started 09:30Z and is still in progress; #6905's last full run on its current head sha was green, its re-run is in progress. Both PRs are behind master (not a merge blocker, but both need a rebase before merge).

结论八问(本 PR 独立审核):

  1. 是什么问题: 外部摘要全部候选失败时,全失败分支直接返回、不进入会话级三次失败/十分钟冷却的连续失败熔断器,重复 compress 会不断向不可用的端点重新派发请求。
  2. 什么原因导致的: applyConfiguredCompression 的外部摘要全失败分支从未调用 noteCompressLoopFailure——熔断器此前只接在 kernel 车道上,外部摘要车道的总失败对它不可见。
  3. 影响范围与严重程度: 配置了不可用/错误外部摘要端点的会话:每次 compress 白烧候选请求(两个候选每次 2 个请求),无任何保护;会话本身仍可用(只是压缩一直失败)——p2,非 p1。
  4. 怎么修复的: 已派发但全失败的批次计入既有熔断器(仅 attempts > 0 且批次 finished/deadline 时计数);熔断器因外部摘要原因置位时在派发前拒绝(按 cause 门控,保证 substrate-destruction 的指示恢复路径仍可派发);新增短拒绝回执;成功折叠或 10 分钟衰减恢复。
  5. 是否有回归问题: 审过的既有行为——置位回执复用逐字保留的 loop-noise 段落(无措辞漂移);新拒绝回执是有意新增(已在 PR 披露);拒绝不延长冷却;部分成功仍经 applyRanges 清计数;无效配置路径行为不变(仍未计数——相对 issue 要求是缺口,不是回归)。触碰路径上未发现回归。
  6. 是否破坏缓存: 否——不改缓存键、前缀稳定性或折叠边界;新拒绝回执不折叠任何内容。
  7. 是否改了设计方向: 否——复用既有熔断器机制,新增一个 cause 值和外部摘要车道上的一个派发前门控。
  8. 是否引入了新的配置: 无——复用既有阈值/冷却。

判定: 代码本身扎实、diff 干净,但本 PR 与 #6905 重复(后者更早、CI 绿、对 issue 要求的覆盖更全)。按先来后到,建议关闭本 PR、保留 #6905——关闭动作需要 owner 执行,我无法关闭 PR。

This branch has not been deployed

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

Projects

None yet

1 participant