feat(tools): preserve sampled output for selective rereading - #566
Open
caihongwei2006 wants to merge 2 commits into
Open
caihongwei2006 wants to merge 2 commits into
caihongwei2006 wants to merge 2 commits into
Conversation
added 2 commits
September 7, 2026 19:00
Keep evidence across long command results without filling the model context. Save sanitized originals for task-scoped line retrieval, preserve their references through pruning, and retain at least 2k at each edge outside the 8k base allocation. Tested: npm test (6790 passed, 2 skipped), npx tsc --noEmit, npm run build Not-tested: manual live-agent verification
Let the agent select a numbered gap directly instead of calculating offset and line count from the preview. Resolve its inclusive source line range and retain block scope during bounded continuation. Tested: npm test (6793 passed, 2 skipped), npx tsc --noEmit, npm run build
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.
Summary
Long command results currently keep only their head and tail, and later context pruning can erase the saved-output reference. Sample across the full result and retain a task-scoped reference so the agent can inspect omitted lines without rerunning the command.
The preview starts with an 8,000-character budget, distributed across
ceil(length / 8000)samples. Each edge keeps at least 2,000 characters through additional allocation; the remaining gaps are evenly spaced. A 36,000-character result therefore returns2000 + 1600 + 1600 + 1600 + 2000source characters, with four 6,800-character gaps.tool_output(output_id, block_id)expands a numbered omitted block into its original inclusive line range; previews include the exact expansion call. The reader also supports selected-line reads and 8k-bounded continuation that stops at the selected block’s final line. Sanitized originals survive idle session rebuilds and are reclaimed on explicit task close; context and persistence guards retain retrieval references. Command/script capability groups include the reader, while legacy explicit whitelists keep the existing file/read fallback. No new production dependencies.Test Plan
npm teston the isolated branch based on currentmainnpx tsc --noEmitnpm run build