You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
parseCompressArgs: content given as a single entry object is rejected (content-not-array) while the same drift at the top level is tolerated — asymmetric salvage wall #470
A model that batch-compresses successfully for thousands of refs occasionally re-issues a lost range with content as the single entry object instead of a one-element array:
parseCompressArgs answers kind=content-not-array (dist parseCompressArgs ~:7232/7239) — a hard failure with no salvage.
Meanwhile the SAME drift at the top level is already tolerated by the salvage ladder: a bare top-level entry object {"startId":..., "endId":..., "summary":...} parses fine. So the ladder's policy ("an entry-shaped object in the wrong slot is recovered") is applied asymmetrically: top-level yes, inside content no. Stringified/fenced variants recovered elsewhere also exist.
Why this matters beyond proxy hosts
billion-context shipped a wrapper-side normalization (normalizeCompressInput in PR #1497) for the proxy lane — but plugin-mode agents execute their own bundled acp-kernel, so those agents keep hitting the wall, and the two worlds now have divergent parse semantics for the same input. Root-cause home per our convention is the kernel ladder.
Suggested fix
In parseCompressArgs, after the Array.isArray(content) check fails, if the value isPlainObject(content) and it looks entry-shaped (has any of startRef/startId/endRef/endId/summary/ranges), wrap it into a one-element array — mirroring the existing top-level bare-object recovery. Diagnostics should record the recovery (e.g. an invalidReasons note or a dedicated kind upgrade) so hosts can observe the drift rate.
Not security-bearing: wrapped entries still pass validateEntry (bounds + summary gates) unchanged.
Context
Original accident: 3-entry batch → 1 entry dropped at parse → silent partial success (proxy receipt side fixed in bili PR #1497) → model retried the lost range with the single-object shape → hard failure.
[bot] 🏷 Fixed — PR: #471 (branch 2026-09-27_content-object-salvage, commit afa1c54, based on master head 6915978).
Triage verification
Reproduced. Against the pre-fix kernel, the exact shape from the issue:
{content: {startId: "m04083", endId: "m04092", summary: ...}} → {ok:false, kind:"content-not-array"}, 0 ranges — hard wall, no salvage
same entry at top level (no content key) → ok, 1 range — tolerated
stringified variant of the object shape → also content-not-array
So the asymmetry is real: the ladder's own policy ("an entry-shaped value in the wrong slot is recovered") was applied at the top level but hard-rejected inside content. Root cause is the final else branch of parseObjectValue in src/parse-compress-input.ts — a gap in the salvage ladder itself, not a host or proxy problem. That confirms your layer judgment: the home for this is the kernel, which is exactly why plugin-mode agents kept hitting the wall while the bili proxy lane got wrapper-side relief (#1497).
What the fix does
In parseObjectValue, when content is neither an array nor a string but is a plain object, it's wrapped into a one-element array and flows through the shared validateEntry pipeline unchanged; if the object instead carries a nested ranges array, that array is unwrapped (you listed ranges among the entry markers, and wrapping it would have failed validation). Two deliberate choices:
Unconditional wrap, not field-gated shape detection. Your suggested fix gated on "looks entry-shaped"; I adopted the unconditional variant because it is byte-for-byte what normalizeCompressInput in billion-context#1497 already does (isPlainObject(c) → content: [c]). Convergence matters more than precision here: with gating, the two lanes could still diverge on e.g. an entry-shaped object with unexpected extra keys. False-positive risk is zero either way, since bounds + summary gates apply unchanged downstream — garbage degrades to per-entry reasons, never to a phantom range.
New additive diagnostic diagnostics.contentSalvage === true marks every recovered input (object wrap and ranges unwrap), so hosts can observe the drift rate exactly as you asked. Canonical array inputs leave it undefined.
String-encoded and fenced double-stringified variants recover automatically (they funnel into the same branch), and rebuildCompressionState benefits without changes. The schema layer (COMPRESS_PARAMETERS) is untouched — it still structurally rejects object-under-content, and its contract test now pins both layers' roles explicitly.
Behavior change (old → new) — required disclosure
Input shape
Before
After
{content: {startId,endId,summary}} well-formed
kind=content-not-array, 0 ranges
kind=ok, 1 range, contentSalvage=true
{content: {foo: 1}} garbage
content-not-array
no-valid-ranges + per-entry reason ("missing range bounds"), still 0 ranges
{content: {ranges: [...]}}
hard fail
unwrapped, parsed normally
{content: 42/null/true}
content-not-array
unchanged
truncated string, single-object content
truncated, 0 ranges
unchanged (partial entries dropped, never guessed)
canonical {content: [...]}
ok
unchanged, no new flag set
Why this is safe: only inputs that previously died with zero ranges are affected, and they can now at best recover entries that pass the identical validation the canonical path uses. Nothing security-bearing shifts.
tests/compress-schema-contract.test.ts: the old "object under content stays rejected" test updated to pin the new two-layer contract (schema strict / parser salvages).
Note for the #1497 side: once this ships, the proxy-lane normalizeCompressInput becomes belt-and-braces rather than load-bearing — you may keep it (defense in depth against older bundled kernels) but the semantics now agree by construction.
Activity
ranxianglei commentedon Sep 27, 2026
[bot] 🏷 Fixed — PR: #471 (branch
2026-09-27_content-object-salvage, commitafa1c54, based on master head6915978).Triage verification
Reproduced. Against the pre-fix kernel, the exact shape from the issue:
{content: {startId: "m04083", endId: "m04092", summary: ...}}→{ok:false, kind:"content-not-array"}, 0 ranges — hard wall, no salvagecontentkey) → ok, 1 range — toleratedcontent-not-arraySo the asymmetry is real: the ladder's own policy ("an entry-shaped value in the wrong slot is recovered") was applied at the top level but hard-rejected inside
content. Root cause is the finalelsebranch ofparseObjectValueinsrc/parse-compress-input.ts— a gap in the salvage ladder itself, not a host or proxy problem. That confirms your layer judgment: the home for this is the kernel, which is exactly why plugin-mode agents kept hitting the wall while the bili proxy lane got wrapper-side relief (#1497).What the fix does
In
parseObjectValue, whencontentis neither an array nor a string but is a plain object, it's wrapped into a one-element array and flows through the sharedvalidateEntrypipeline unchanged; if the object instead carries a nestedrangesarray, that array is unwrapped (you listedrangesamong the entry markers, and wrapping it would have failed validation). Two deliberate choices:normalizeCompressInputin billion-context#1497 already does (isPlainObject(c) → content: [c]). Convergence matters more than precision here: with gating, the two lanes could still diverge on e.g. an entry-shaped object with unexpected extra keys. False-positive risk is zero either way, since bounds + summary gates apply unchanged downstream — garbage degrades to per-entry reasons, never to a phantom range.diagnostics.contentSalvage === truemarks every recovered input (object wrap and ranges unwrap), so hosts can observe the drift rate exactly as you asked. Canonical array inputs leave itundefined.String-encoded and fenced double-stringified variants recover automatically (they funnel into the same branch), and
rebuildCompressionStatebenefits without changes. The schema layer (COMPRESS_PARAMETERS) is untouched — it still structurally rejects object-under-content, and its contract test now pins both layers' roles explicitly.Behavior change (old → new) — required disclosure
{content: {startId,endId,summary}}well-formedkind=content-not-array, 0 rangeskind=ok, 1 range,contentSalvage=true{content: {foo: 1}}garbagecontent-not-arrayno-valid-ranges+ per-entry reason ("missing range bounds"), still 0 ranges{content: {ranges: [...]}}{content: 42/null/true}content-not-arraytruncated, 0 ranges{content: [...]}Why this is safe: only inputs that previously died with zero ranges are affected, and they can now at best recover entries that pass the identical validation the canonical path uses. Nothing security-bearing shifts.
Tests & pre-flight
tests/parse-compress-input.test.ts, parseCompressArgs: content given as a single entry object is rejected (content-not-array) while the same drift at the top level is tolerated — asymmetric salvage wall #470 section): wrap + flags, per-entry/top-level topic & summaryMaxChars, compressCallId stamping, string-encoded + fenced double-stringified, nested-ranges unwrap, garbage/incomplete degradation, truncated non-guessing, non-object values unchanged, canonical unmarked, rebuild end-to-end.tests/compress-schema-contract.test.ts: the old "object under content stays rejected" test updated to pin the new two-layer contract (schema strict / parser salvages).Note for the #1497 side: once this ships, the proxy-lane
normalizeCompressInputbecomes belt-and-braces rather than load-bearing — you may keep it (defense in depth against older bundled kernels) but the semantics now agree by construction.Merge pull request #471 from ranxianglei/2026-09-27_content-object-sa…
fix: salvage single-entry object in the compress content slot (ranxia…