Repository navigation
fix: surface parse-dropped compress entries; normalize single-object content (#1494) - #1497
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1438-pr.1497.3fffc4aThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1497.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…content (#1494) Two param-shape defects in the proxy compress path: 1. Silent partial failure: entries a batched compress call contained that the kernel parser rejected (bad bounds, missing summary, broken JSON fragment) vanished from the receipt — 'Compressed A, B → 2 block(s)' with no note about the dropped entry and no server log line (the warn only fired when ALL entries failed). Models believed the fold landed and never re-issued the lost range. 2. Asymmetric shape tolerance: retrying the lost range with content given as the single entry object (or a bare top-level array / string-encoded variants) hit kernel kind=content-not-array/not-object — a hard failure on shapes the kernel's salvage ladder already accepts at the top level. Fixes: - normalizeCompressInput (src/compress-tool.ts): wrap single-object content in a one-element array, bare top-level arrays into {content:[…]}, and recover the same shapes from string-encoded args (fenced / double- stringified). Canonical inputs pass through byte-identical. - applyRanges (src/stream.ts): append a model-facing REJECTED note with the kernel per-entry reasons to BOTH the success receipt and the 0-blocks failure message; log server-side ('compress PARTIAL'). - parseCompressInput: warn-log partial drops (previously invisible because diagnostics.ok was true whenever ≥1 range survived). Behavior changes (disclosed): - Previously hard-failing param shapes are now accepted (single-object content, bare array, their string-encoded variants): old = full call failure, new = normalized fold. - Tool receipts gain an optional extra line on partial drops: old = silent under-reporting, new = explicit rejection note + re-issue guidance. - Garbage object content now reports kind=no-valid-ranges with per-entry reasons instead of opaque content-not-array (still a failure).
3d6d0c4 to
ea53130
Compare
[bot] 🏷 Review complete — #1497 is correct, green, and mergeable once coordinated with parallel PR #1499 (the ① Direction check (vs #1494) ✅
② Regression audit (existing behaviors on the touched paths, read from pre-change code)
③ Code review — sound. Minor, non-blocking observations:
④ Test validity ✅ — 8 tests with teeth: both defects reproduce pre-fix (silent partial success; ⑤ Diff cleanliness ✅ — 3 files, +217/−3, every line on-purpose. No lockfile/generated/whitespace churn. Evidence (rebased head)
Division of unique value (verified against both diffs + kernel source):
Neither alone covers the full incident class. Kernel evidence (pinned acp-kernel 0.0.95, Recommendation: merge this PR first (fully green above), then rebase #1499 to strip its overlapping invalidItems note/log and keep its unique parts (truncated branch + Verdict: mergeable once coordinated with #1499 — this PR alone is complete, correct, and green; the sole risk is receipt-text duplication from the sibling PR landing without dedupe. Merge stays human-only. 一句话中文摘要:修复了批量压缩部分失败时静默丢条目(回执只报成功、无日志)与单对象 content 重试被硬拒两个缺陷,修在参数归一化+回执合成的决策点而非过滤症状;已 rebase 到当前 master,本地与 CI 全绿(含 codex e2e);注意与 #1499 改同一批回执行需去重协调——本 PR 独有形状归一化、#1499 独有 truncated-salvage 可见性,二者缺一都覆盖不全本次事故,建议先合本 PR、再让 #1499 rebase 去重后合并,合并由人来执行。 |
Deep review: verified, two merge-prep follow-ups applied ✅Independent reviewer pass (mutation-verified) confirms both fixes are real, correctly implemented, and pinned:
Applied on top (head
|
Root cause
Issue #1494 reported two things in the same session:
compresscall with 3 entries applied only 2 — "Compressed m02815–m03212, m04083–m04092 → 2 block(s)" — with no note about the dropped entry. The kernel parser already reports per-entry rejections indiagnostics.invalidReasons, butapplyRangesonly surfaced them when all entries failed (ranges.length === 0). When ≥1 range survived,diagnostics.ok === true, so neither the model-facing receipt nor the server log mentioned the drop — the receipt'sdetaillists only surviving ranges, so a 3-entry call read as a clean 2-block success.contentgiven as the single entry object hitkind=content-not-array, dropped=0— a hard failure. The kernel's salvage ladder already accepts a bare{startId,…}at the TOP level as one range, but hard-rejects the same shape INSIDEcontent. Bare top-level arrays (kind=not-object) and string-encoded variants fall into the same wall.The summary-length hypothesis from the issue does not hold: the per-summary cap is 20000 chars (#888) and a cap breach fails the WHOLE call atomically with "Summary too long" — it cannot drop one entry of three. The drop happened at argument parse time (e.g. an unescaped quote/newline inside the long summary corrupting the array, salvaged entries minus the broken fragment).
Changes
src/compress-tool.ts: newnormalizeCompressInput()runs before the kernel parse — wraps single-objectcontentin a one-element array, bare top-level entry arrays into{content:[…]}, and recovers the same shapes from string-encoded args (fenced / double-stringified). Canonical inputs pass through byte-identical (asserted).src/stream.tsapplyRanges: appends a model-facing REJECTED note carrying the kernel's index-prefixed reasons to BOTH the success receipt and the 0-blocks failure message; logs[acp-proxy: compress PARTIAL …]server-side.src/compress-tool.tsparseCompressInput: warn-logs partial drops (previously invisible becauseokwas true whenever ≥1 range survived).tests/issue1494-compress-params.test.ts: 8 regression tests — both defects reproduced pre-fix (silent partial success; content-not-array on single-object content), plus pass-through guarantees for canonical/empty/line-form inputs.Behavior changes (disclosed)
content= single entry object / bare top-level array / string-encoded variantscontent-not-array/not-object){foo:1})kind=content-not-arraykind=no-valid-rangeswith per-entry reason (still a failure)Proxy mode only: plugin-mode agents own their folds and never route through
applyRanges, so plugin mode is untouched. No wire/upstream protocol change — tool-result text gains an optional extra line.Pre-flight
npm run typecheck✅npm test✅ 2879 pass / 0 fail / 12 skipped (pre-existing skips)npm run build✅src/stream.ts(request-pipeline hot file), soci-e2e.ymlauto-runs on this PR.Note: #1495 reports the exact same transcript/incident (lean-mode framing) — this fix is mode-independent (proxy-layer param handling); one PR covers both.
Closes #1494
Fixes #1494
Fixes #1495