Skip to content

[PR] fix(compress): teach ONE-call single-string re-issue in loss receipts - #1520

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-27_compress-receipt-batch-teaching
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-09-27_compress-receipt-batch-teaching

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #1495

What

Owner re-review on #1495 (15:31): after the honest-loss receipts landed, models stopped batching compress and issue one call per range — the lossy gateway corrupted their array batches, receipts told them what was lost, and the transcript shows them rationally concluding "single-range LINE FORM is the most robust path". Functionally equivalent, but it multiplies compress turns and pollutes the conversation.

The escape hatch already exists in the kernel parser (splitLineEntries): ONE plain string may carry MULTIPLE ranges, each block starting with its own mNNNNN–mNNNNN optional topic header line — no array nesting for a gateway to stringify, and truncation salvage recovers every complete leading block. It was simply never documented anywhere the model looks.

This PR teaches that form exactly where the model is recovering from a loss (src/stream.ts, 4 receipts):

  • truncated-salvage receipt: "Re-issue ALL missing ranges TOGETHER in ONE new call, as a single plain string — one block per range, each block starting with its 'mNNNNN–mNNNNN optional topic' header line…"
  • multi-entry rejection receipt (n>1): "Re-issue ALL rejected ranges TOGETHER in ONE new compress call — a single plain string works…" (n=1 text deliberately unchanged)
  • unparseable-JSON receipt: adds the plain-string content escape to the re-issue guidance
  • no-valid-ranges format lecture: documents that content may be ONE plain string carrying ALL ranges

Tests

  • 2 new: multi-entry rejection teaches batch re-issue (issue1494 file); truncated receipt pins "Re-issue ALL missing ranges TOGETHER" + "single plain string" (issue1495 file).
  • 1 deliberate pin update: compress-observability Opencode V2: Compress Function Call Mangled In LLM Output #1366 lecture tail (Re-issue the compress call with a valid content array → Re-issue ALL intended ranges in ONE compress call).
  • Local: tsc -p tsconfig.build.json 0; issue1494 + issue1495 + compress-observability 29/29; all applyRanges-touching files 138/138; issue1502 raw-args-salvage 7/7.

Pairs with

Kernel side (tool descriptions + nudge hint teach the same form): ranxianglei/acp-kernel#472 — pin bump follows after that releases.

…#1495)

Owner re-review on #1495: after the honest-loss receipts, models stopped
batching — the lossy gateway killed their array calls, so they rationally
retreated to one-range-per-call, multiplying compress turns. The kernel
parser has always accepted ONE plain string carrying MULTIPLE ranges
(each block starting with its refs header line); teach that form exactly
where the model is recovering from a loss:

- truncated-salvage receipt: re-issue ALL missing ranges TOGETHER in ONE
  call as a single plain string
- multi-entry rejection receipt: same teaching (n>1 only; the n=1 text
  stays unchanged)
- unparseable-JSON receipt: mention the plain-string content escape
- no-valid-ranges format lecture: document the multi-range string form

Pinned texts updated deliberately (compress-observability #1366 lecture
tail); 2 new tests pin the batch teaching.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-27_compress-receipt-batch-teaching (bd52156)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1464-pr.1520.2b80023

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

Option B — Download artifact

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

Review complete — mergeable. Verified on a local rebase onto current master (86e0b684, which includes #1519): rebase applied with zero conflicts, tsc clean, full suite 3002 pass / 0 fail / 12 skipped. CI was already all-green on head bd52156d (ubuntu 22/24, windows 22/24, e2e codex, hermetic registry, build-artifact, version-guard).

① Direction (original issue) — correct, and I verified the load-bearing claim rather than taking it on faith. Owner re-review on #1495 (floor 6): after #1499's honest-loss receipts, models retreated to one compress call per range — functionally equivalent, but multiplied turns. This PR teaches the existing escape hatch where the model actually recovers from a loss (the 4 receipts), instead of patching symptoms elsewhere. Critically, I checked the pinned kernel: acp-kernel@0.0.97 already parses the multi-block bare-string form — parseObjectValue falls back to stripJsonWrapperResidue + splitLineEntries for plain-string content (kernel dist, splitLineEntries splits on \n(?=…[mb]\d{1,7}…(dash|…|to)…[mb]\d{1,7}\b)), so each block starting with its own mNNNNN–mNNNNN header is a real, parseable entry today. No pin-bump dependency: acp-kernel#472 is open and docs-only (tool descriptions + nudge hint teaching the same form), consistent with "pin bump follows after that releases". The en-dash in the receipts' header example matches what the kernel regex accepts.

② Regression review — existing behaviors on the touched paths, item by item:

  • truncated-salvage receipt: loss disclosure unchanged ("only the complete leading entries could be salvaged … LOST, not compressed"); only the re-issue guidance grew. Wording-only, disclosed. ✓
  • rejected-entries note: the n==1 branch is byte-identical to before (still pinned by tests/issue1494-compress-params.test.ts:119); only the n>1 branch changed from a generic plural sentence to the batch instruction. Rejection count/facts untouched. ✓
  • unparseable-JSON FAILED receipt: core message unchanged; an escape clause was appended. The adjacent "Do not retry the same corrupt byte string" anti-loop guidance is intact. ✓
  • no-valid-ranges lecture: documents the plain-string form + tail changed Re-issue the compress call with a valid content array. → Re-issue ALL intended ranges in ONE compress call. This is the deliberate Opencode V2: Compress Function Call Mangled In LLM Output #1366 pin update. Checked against Opencode V2: Compress Function Call Mangled In LLM Output #1366's intent (loop-bait removal): the negative pins at tests/compress-observability.test.ts:130,139 still hold, and the new tail steers toward a corrected form (not the same broken bytes), with the repeat-failure guard still appended on repeated specs. Consistent. ✓
  • No config schema, persistence, wire-shape, or cross-repo pin changes; receipts are tool-result text, safe in both compression modes.

③ Code — pure string edits plus one n>1 vs n==1 ternary in droppedEntriesNote; condition correct. All four receipts live exclusively in src/stream.ts (grep-audited the whole tree — no duplicated copies in adapters/loop). Nothing to fix directly.

④ Test validity — the new multi-entry rejection test has teeth: it submits [valid, {startId:"m00003"}, {summary:"no refs"}] and asserts the success annotation carries "REJECTED and NOT compressed" + the new batch phrases — fails against the old text, so it nails the n>1 branch. The two truncated-receipt assertions pin the salvage path's new guidance. The single pin update is legitimate (deliberate, disclosed text change). Parsing of multi-block strings is correctly left to kernel-side tests — right scope split.

⑤ Diff cleanliness — 4 files, +28/−5, every line purpose-related; no version bump, no lockfile churn, no whitespace noise. No open-PR contention on these regions.

Verdict: root-cause fix at the decision point (the receipts are exactly where the model decides its recovery strategy), backed by verified kernel support in the currently-pinned version, with regression teeth on both new branches. Safe to merge; the acp-kernel#472 pin bump can follow once that releases.

修复了 #1499 诚实回执引发的副作用(模型退回单区间逐次调用、压缩轮次膨胀):在 4 处损失回执中教会模型内核本就支持的「单个纯字符串承载多区间」批量重发格式,已验证当前锁定的 acp-kernel 0.0.97 确实能解析该格式、rebase 到最新 master 后全套测试通过,可以合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

陈旧票清理(第三批动作①):目标 issue #1495 已关。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。

@ranxianglei ranxianglei changed the title fix(compress): teach ONE-call single-string re-issue in loss receipts [PR] fix(compress): teach ONE-call single-string re-issue in loss receipts Oct 24, 2026
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.

lean模式批量压缩丢失

1 participant