Skip to content

feat: salvage unparseable compress args in replay (fixes #121) - #123

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

feat: salvage unparseable compress args in replay (fixes #121)#123
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 (this repo's issue #121). In replay, compressToolArgs was strict-only: an unparseable argument blob aborted the replayed compress call with Invalid content: not valid JSON, so a single malformed tool call from the model killed the whole session replay.

What

Route compressToolArgs through acp-kernel's parseCompressInputStringsalvageParseRanges (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 + extractRanges double-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) ---

⚠️ 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 the registry and the full suite re-run.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant