feat: salvage malformed compress content strings (omp#121) - #196
Open
ranxianglei wants to merge 1 commit into
Open
feat: salvage malformed compress content strings (omp#121)#196ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
normalizeRangesthrewInvalid content: not valid JSONon 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
salvageParseRangesladder (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 theisError:true→ retry-nudge contract is unchanged.Bumps acp-kernel to ^0.0.34 (introduces
salvageParseRanges+extractRangesdouble-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) ---