fix: Context Overload in Read File Tool#6319
Closed
liwilliam2021 wants to merge 14 commits intomainfrom
Closed
Conversation
Contributor
Author
This was referenced Jul 28, 2025
cte
approved these changes
Jul 29, 2025
Collaborator
cte
left a comment
There was a problem hiding this comment.
I think in general the strategy is good, but I left a few questions / comments. Separately, I'm going to test this in a few scenarios just to get a sense of how it behaves.
daniel-lxs
approved these changes
Aug 2, 2025
mrubens
requested changes
Aug 2, 2025
Collaborator
mrubens
left a comment
There was a problem hiding this comment.
I would really like to find a solution that doesn’t require special casing of minified files. Can we try reading lines in chunks instead of reading to the newline every time?
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This was referenced Aug 4, 2025
Contributor
Author
resolved! |
|
Is there a plan to merge this soon? |
This was referenced Sep 9, 2025
Collaborator
|
Stale. Implementation not the one we want. |
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.
Fix Context Overload in Read File Tool
Problem
The read_file tool could attempt to read files that exceed the available context window, causing API failures and poor user experience.
Solution
Added preemptive context validation that dynamically calculates available space and applies intelligent file size limits.
Changes
New contextValidator module:
Enhanced readFileTool:
Fix
Turn off partial reads, and open Roo-Code-Evals/javascript/lodash. Ask the following prompt from this task: https://app.roocode.com/share/fa7affcc-611d-46ff-89a4-d741d8593b2a
Remaining concerns:
Fixes #7744
Important
Introduces context validation in the Read File Tool to prevent context overload by dynamically calculating available space and applying file size limits.
contextValidatormodule to calculate available context space and apply file size limits.readFileToolto validate file size before reading and provide instructions for truncated files.contextValidator.test.tsto test context validation logic.readFileTool.spec.tsto test file reading with context validation.read-partial-content.spec.tsto test partial content reading.providerFormat.spec.tsto test provider format logic.api.tsto include provider format mapping logic.This description was created by
for 2285015. You can customize this summary. It will automatically update as commits are pushed.