Skip to content

feat: salvage malformed compress content strings (omp#121) - #196

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-08-22_compress-arg-salvage
Open

feat: salvage malformed compress content strings (omp#121)#196
ranxianglei wants to merge 1 commit into
masterfrom
2026-08-22_compress-arg-salvage

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Why

Weak/local models (vLLM qwen etc.) emit compress tool arguments that fail strict JSON.parse ~50% of the time — truncated output caps, raw newlines inside summary strings, trailing commas, or plain prose (see billion-context-omp#121). The ACP host extension's normalizeRanges threw Invalid content: not valid JSON on the first strict-parse failure and relied entirely on the retry nudge — but weak models fail the retry the same way ~50% of the time, so compress became effectively unusable with local models.

What

Before throwing, run the kernel's salvageParseRanges ladder (fences / comma+newline repairs / truncated-array prefix / field-regex): recoverable entries proceed as normal ranges (logWarn records the layer); truly unparseable input still throws, so the isError:true → retry-nudge contract is unchanged.

Bumps acp-kernel to ^0.0.34 (introduces salvageParseRanges + extractRanges double-encode normalization).

Tests

New truncated-content salvage case in tests/compress-retry.test.ts (first complete entry recovered from a blob truncated mid-second-entry). Full suite 410/410, typecheck clean.

Companion PRs: acp-kernel#109 (parser), billion-context (proxy), billion-context-omp (replay).

--- DEPENDENCY NOTE (pre-publish) ---

⚠️ Do not merge yet: package.json currently pins acp-kernel to a local file: tarball so the diff is reviewable now. Depends on acp-kernel PR #109 landing and npm publish of 0.0.34 (0.0.33's publish failed with npm 404 — expired NPM_TOKEN). Before merge this PR will be updated to "acp-kernel": "^0.0.34" from from the registry and the full suite re-run.

Weak/local models emit truncated or malformed JSON in compress content
~50% of the time (see billion-context-omp#121). normalizeRanges threw
'Invalid content: not valid JSON' on the first strict-parse failure and
relied entirely on the retry nudge. Now, before throwing, run
acp-kernel's salvageParseRanges ladder (fences / comma+newline repairs /
truncated-array prefix / field-regex): recoverable entries proceed as
normal ranges (logWarn records the layer), truly unparseable input still
throws so the isError:true → retry-nudge contract is unchanged.

Bump acp-kernel to 0.0.33 (introduces salvageParseRanges).

tests: truncated-content salvage in compress-retry.test.ts; 410 pass.
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.

1 participant