feat: salvage unparseable compress args in replay (fixes #121) - #123
Open
ranxianglei wants to merge 1 commit into
Open
feat: salvage unparseable compress args in replay (fixes #121)#123ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
Weak/local models emit compress tool arguments that fail strict JSON.parse ~50% of the time (truncated output caps, raw newlines in summaries, trailing commas). compressToolArgs() returned null on the first JSON.parse failure, silently dropping those compress calls from stream replay — compression the model believed it performed never happened on reload. On strict-parse failure, route through acp-kernel's salvageParseRanges (5-layer lenient ladder: strict/fenced/repaired JSON, truncated-array-prefix brace scan, field-regex). Recovered ranges replay normally; logWarn records which layer fired. Truly unparseable payloads still drop, unchanged. Bump acp-kernel to 0.0.33 (introduces salvageParseRanges). tests: truncated-args salvage + garbage-still-drops in messages.test.ts; 259 pass across suite.
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 (this repo's issue #121). In replay,
compressToolArgswas strict-only: an unparseable argument blob aborted the replayed compress call withInvalid content: not valid JSON, so a single malformed tool call from the model killed the whole session replay.What
Route
compressToolArgsthrough acp-kernel'sparseCompressInputString→salvageParseRanges(5-layer ladder: strict JSON / fenced / repaired / truncated-array prefix / field-regex). Recovered entries proceed as normal ranges (log records the salvage layer); only truly unparseable input still throws, preserving the existing error contract.Bumps acp-kernel to ^0.0.34 (introduces
salvageParseRanges+extractRangesdouble-encode normalization).Fixes #121.
Tests
6 new salvage cases in
tests/replay.test.ts. Full suite 259/259, typecheck clean.Companion PRs: acp-kernel#109 (parser), billion-context (proxy), billion-context-pi (ACP host extension).
--- DEPENDENCY NOTE (pre-publish) ---