Skip to content

fix: failed compress receipts name the live compressible span (#1026) - #1036

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-20_compress-span-hint
Sep 20, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-20_compress-span-hint

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #1026
Slimmed maintainer port of #1008 (credit: @asuan-dev — the idea, the head commit, and the kernel-error analysis are theirs).

What

Both failed-compress receipts — no valid ranges parsed and blocksCreated === 0 — now append a live compressible span hint: the raw-ref range NOT covered by an ACTIVE block right now:

Live compressible refs: m00038–m00050 (everything up to m00037 is already inside active blocks). Retry NOW in this same turn with startId/endId inside that span.

When nothing raw is compressible, the receipt names the active blocks' real ids instead:

No raw refs are directly compressible right now — compress a run of ACTIVE blocks instead (e.g. startId b7, endId b11): fold their summaries into one higher-tier block. acp_status lists the current active blocks.

Why (#1026)

A model whose compress fails keeps anchoring on refs an earlier fold already consumed: it re-issues the same dead range, burns retries, then gives up and lets the nudge re-fire every turn (observed live 2026-09-18: three consecutive failed compresses, two full T1 checkpoints wasted). Kernel errors say "run acp_status" — still one extra round-trip. The hint hands over the live span directly; one retry recovers.

Coordinates with the #849 repeat-failure guard: the guard forbids repeating the same dead ranges; the hint supplies the live ones.

Notable details

Pre-flight

  • npm run typecheck ✅
  • npm test — 2029 pass / 0 fail / 2 skipped ✅ (5 new tests in tests/compress-span-hint.test.ts)
  • npm run build ✅

@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-20_compress-span-hint (c56fd04)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1036

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

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1036.tgz
npm install -g package

Install instructions are refreshed on each push.

Port of PR #1008's head commit, slimmed to just the span hint: both failure
receipts (no-valid-ranges and blocksCreated===0) append compressibleSpanHint()
— the raw-ref span not covered by an ACTIVE block — so one retry lands on a
valid range instead of re-issuing refs an earlier fold consumed. Boundary
counts active blocks only (decompress releases it); exhausted fallback names
real active block ids for a higher-tier b-range fold (kernel-first-class).

Co-authored-by: asuan-dev <asuan_10907@163.com>
@ranxianglei
ranxianglei force-pushed the 2026-09-20_compress-span-hint branch from 49cbd4c to c56fd04 Compare September 20, 2026 05:15
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewed PR #1036 — verified, rebased onto current master, green. Ready for a human merge (I can't merge PRs — system rules forbid it).

Diff review (first gate: cleanliness) — 3 files, +123/−2, every line serves #1026:

  • src/stream.ts:66-79 — new compressibleSpanHint(state); wired into exactly the two receipts named in the description: src/stream.ts:150 (no-valid-ranges) and src/stream.ts:207 (blocksCreated===0).
  • tests/compress-span-hint.test.ts — 5 regression tests (span past highest ACTIVE block, inactive-block boundary release, exhausted fallback naming real ids, both receipt paths carrying the span).
  • CHANGELOG.md — Unreleased entry. No lockfile churn, no version bump, no whitespace noise.

Correctness checks:

  • Kernel contract verified against the pinned acp-kernel: Block has active + optional startRef/endRef (the code correctly guards with ?.startsWith("m")), messageRefs.byRef is Record<string,string>, and deactivateBlock exists as used by the test.
  • Both compression modes considered: the change only alters error-receipt text (returned as the tool result) — no wire/message-shape change, so plugin mode (agent sees the receipt in its own history) and proxy mode (ephemeral loop) both benefit identically. The applied.startsWith("[Compression FAILED") check at src/preflight.ts:1018 is unaffected by the appended hint.
  • Boundary semantics spot-checked: max endRef over ACTIVE blocks only → decompress releases the span (test 2 pins this); conservative single span above the newest boundary is valid even when earlier gaps are also compressible.

Rebase (was required): the PR base (3adc9ac) was stale — master moved under it (release v0.1.127 + PR #867 Google wire). Rebased the single commit onto current master (c366828): zero conflicts, byte-identical diff, pushed with --force-with-lease (single agent-authored commit, nothing lost). Head is now c56fd04.

Pre-flight on the rebased head (not just the original SHA):

Two non-blocking observations (left as-is, your call):

  1. A third failure path exists — the catch-all exception receipt at src/stream.ts:259 (kernel throws inside applyCompression). It carries no hint. State is still consistent there (assignment happens after the call returns), so appending the hint would be safe; I kept the port exactly at its stated scope instead of expanding it. Candidate for a follow-up if you want all three receipts covered.
  2. Degenerate case: zero refs mapped and zero active blocks → the fallback names active blocks that don't exist. Practically unreachable (a compress call implies messages exist); noted for completeness.

结论(中文摘要):已核对 diff(干净、每行都服务于 #1026)、验证了内核契约与两种压缩模式,把 PR rebase 到最新 master(c56fd04)并在其上重跑 typecheck/test/build 全绿——修复了失败压缩回执缺少"当前可压缩区间"提示导致模型反复重试死区间的问题,可以合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI update on rebased head c56fd04: all 8 checks passed ✅ — build-artifact, version-guard, both codex e2e runs, and the full test matrix (ubuntu 22/24, windows 22/24). Nothing left outstanding on my side; the PR is ready whenever you merge it.

CI 全绿(8/8),rebase 后的 c56fd04 上构建、版本守卫、codex e2e、双平台测试矩阵全部通过,可以合并。

@ranxianglei
ranxianglei merged commit d598485 into master Sep 20, 2026
8 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-20_compress-span-hint 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 回执中给出当前可压缩区间 — 社区 PR #1008 (@asuan-dev)

1 participant