(fix) page large-block decompress output with offset/limit so one recovery can't flood or get silently trimmed - #118
Open
ranxianglei wants to merge 1 commit into
Conversation
This was referenced Sep 6, 2026
Contributor
Author
|
我来协助看一下这个问题,请分析并回复处理结果。 |
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.
Fixes #112.
Problem
decompress(and/acp decompress) expands ALL shadowed seqs of a block into one uncapped tool result. For a large block (say 200K tokens) the recovered text either floods the model's context or — more usually — gets silently truncated by the host tool-result pruner (dsh-compaction-tool-result-pruner, tiers 8192/4096/1024): the tail of the recovered content is gone while the model believes it holds the whole block. That is precisely the failure mode decompress exists to undo.Cause
handleDecompress(src/tools.ts) joinsexpandShadowedSeqs(session, block.blockId)into a single string; the tool schema only exposesblockId, so there is no way to page through.Fix
sliceDecompressPage(expanded, offset, limit)+DEFAULT_DECOMPRESS_PAGE = 100(src/region.ts): pure paging helper shared by the tool and the command. Clampsoffset >= 0,limit >= 1; empty-text seqs still occupy slots so paging stays stable across calls.decompresstool: optional integeroffset/limitparams. Results end with[messages X..Y of Z]plus an explicit continue hint (decompress({ blockId: "<id>", offset: N })) when more remains; an offset past the end returns guidance instead of an error./acp decompress <blockId> [offset] [limit]: same paging and footer (8-char prefix form); non-numeric args are rejected.Small blocks behave as before (a
<= 100message block returns whole, plus the new[messages X..Y of Z]footer).Verification
[messages 1..100 of 120]+ continue hint, walks to the final page via offset, and checks past-end guidance.npm run typecheckclean;npm test211 pass / 0 fail (208 baseline + 3 new);npm run buildclean (dist committed per AGENTS.md §4).Built against main @ 6348af8 (v0.2.20).