Skip to content

fix: conclusive compress failure receipt when conversation is below minCompressRange - #1128

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-22_compress-failure-receipt
Sep 22, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-22_compress-failure-receipt

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Piece 1 of the owner-approved split of PR #1121 (whose surface-gating half was rejected as symptom-treatment and stays out of scope here), re-applied standalone on current master per the split directive.

In src/stream.ts applyRanges failure path: when minCompressRange > 0 && totalChars < minCompressRange (totalChars = sum of visible message text lengths), append one sentence to the existing failure receipt:

This conversation holds only N char(s) — below the MIN-char minimum, so NO range can succeed yet; do not retry compress or call acp_status/search_context about it — continue answering the user's task.

The kernel reason string and the #847 reversal note stay intact; the sentence is appended after them. When a larger viable range exists (totalChars ≥ floor), the generic advice is unchanged.

Why

When the WHOLE conversation is under the floor, no range combination can succeed — the kernel sums chars across requested ranges against the single threshold. The generic "combine more messages…" advice at that moment pushes the model straight back into compress retries and acp_status/search_context inspection loops (#1112: a fresh Codex session burned follow-up turns exactly this way). This is root-cause factor 3 of #1112 (failure → re-request loop): the receipt itself was steering the model onto the ACP tool loop. Fixing it at the decision point (the receipt) rather than masking the symptom elsewhere.

Scope / invariants

Tests

New tests/fix-1124-compress-receipt.test.ts (3 regression tests, adapted from the #1121 receipt tests to current-master harness conventions):

  1. sub-floor conversation → receipt contains the conclusive verdict (and preserves the kernel reason);
  2. viable larger range exists → generic "Combine more messages" advice kept, no verdict;
  3. minCompressRange: 0 → legacy behavior, tiny compress succeeds, no verdict.

Pre-flight on rebased head (master @ aeeed25, branch base):

  • npm run typecheck — clean
  • npm test — 2203 tests: 2201 pass, 0 fail, 2 skipped (pre-existing env-gated skips)
  • npm run build — success

E2E note: full e2e suite not run from this sandbox (its upstream is infra-local); the change is failure-time tool-result text only, covered by the regression tests above.

Closes #1124

…inCompressRange

When the WHOLE visible conversation holds fewer chars than compress.minCompressRange, no range combination can succeed (the kernel sums range chars against the single threshold), yet the standard failure receipt gave only generic 'combine more messages' advice — steering models straight back into compress retries and acp_status/search_context inspection loops (root-cause factor 3 of #1112).

Append one conclusive sentence to the applyRanges failure receipt when minCompressRange > 0 and total visible chars < minCompressRange: the floor is unreachable for any range, so do not retry compress or inspect ACP state about it. Kernel reason string and the #847 reversal note stay intact; when a viable larger range exists the generic advice is unchanged. No config schema change, no wire-shape change beyond failure-time tool-result text, plugin mode unaffected (receipt text only).

Piece 1 of the owner-approved split of PR #1121 (surface-gating half stays out of scope); re-applied standalone on current master per the split directive.

Closes #1124
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-22_compress-failure-receipt (32ebdf3)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1128

Each push to this PR publishes a new version under the pr-1128 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1128.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

Reviewed PR #1128 end-to-end (pulled 2026-09-22_compress-failure-receipt @ 32ebdf3, verified diff, re-ran pre-flight locally, checked CI). Conclusion: ready for human merge. #1128

Diff audit (clean)

  • Single commit on current master (aeeed25 confirmed as merge-base — no stale base, no rebase needed). Two files: src/stream.ts (+15/−1) + new tests/fix-1124-compress-receipt.test.ts (+77). No unrelated files, no whitespace/lockfile churn.
  • Hunk sits exactly on the r.blocksCreated === 0 failure path in applyRanges (src/stream.ts:238), as the issue claims — the size-gate rejection path where the kernel returns errors without throwing. Kernel reason (errs) and the 出现持续压缩失败,无法自动恢复 #847 reversal note stay intact; the verdict sentence is appended after them, receipt stays one line (client marker safe, ACP 状态标记被拼接进用户消息文本块;跨会话代际 stale refs 压缩整批失败 #1029 invariant preserved).
  • Config field verified: ctx.config.compress.minCompressRange is the same effective field read by src/acp-status.ts:61 and src/preflight.ts:806; user config minCompressRangeChars (canonical) and legacy minCompressRange both map into it via src/compress-settings.ts:245. Consistent with repo convention.
  • Tests match the three promised scenarios (sub-floor → conclusive verdict + kernel reason preserved; viable larger range → generic "Combine more messages" kept, no verdict; minCompressRange: 0 → legacy behavior). Harness follows current-master conventions (node:test, _setStoreForTest, kernel defaultConfig).

Local pre-flight on PR head (re-run by me, not just taken from the PR body)

  • npm run typecheck — clean
  • npm test — 2203 tests: 2201 pass, 0 fail, 2 skipped (pre-existing env-gated) — matches the PR's claimed numbers exactly
  • npm run build — success

CI (all on the PR branch)

Full e2e couldn't be re-run from this sandbox (local sglang upstream unreachable here), but the CI fake-codex e2e lane covers it and is green.

One non-blocking observation (noting, not changing — the hunk is applied verbatim per the owner-approved split): totalChars sums over ctx.messages (the processed view, reasoning/kernel-summaries stripped — server.ts:2230/2387), while the kernel's size gate runs against ctx.compressMessages ?? ctx.messages = originalMessages (server.ts:4496). In a narrow case where stripped content (e.g. a large acp_summary plus tiny fresh text) straddles the floor, the verdict could say "NO range can succeed" while a range spanning the summary would pass the kernel gate. Rare (default floor 5000 chars) and low consequence (model skips one retry that could have worked once); flagging for the record rather than reopening scope.

Scope/invariants check: no config schema change, no wire-shape change beyond failure-time tool-result text, plugin mode unaffected (receipt text only), no load-bearing infra touched. Passes the §7.4 auto-merge gate criteria — but merge stays human per policy.


中文摘要:修复了会话整体低于 minCompressRange 时压缩失败回执仍给"合并更多消息"建议、把模型带进 compress/acp_status 重试循环的问题(#1112 根因因子 3),在失败回执决策点追加确定性结论句;已核对 diff 干净、本地 typecheck/test(2201 过)/build 全绿、CI 四条流水线全绿,可以合并。

@ranxianglei
ranxianglei merged commit 407669b into master Sep 22, 2026
8 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-22_compress-failure-receipt branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compress failure receipt: tell the model not to retry when the whole conversation is below minCompressRange

1 participant