fix: wire up maxReadFileLine setting to ReadFileTool#11755
Draft
roomote[bot] wants to merge 1 commit intomainfrom
Draft
fix: wire up maxReadFileLine setting to ReadFileTool#11755roomote[bot] wants to merge 1 commit intomainfrom
roomote[bot] wants to merge 1 commit intomainfrom
Conversation
The maxReadFileLine setting existed as a type definition and in the webview default state but was never actually wired into the ReadFileTool or the tool description. The tool always used the hardcoded DEFAULT_LINE_LIMIT of 2000 lines regardless of the setting. This commit: - Adds maxReadFileLine to ClineProvider.getState() so it flows through the state pipeline - Passes maxReadFileLine through getNativeTools -> createReadFileTool so the tool description reflects the actual configured limit - Uses maxReadFileLine in ReadFileTool.processTextFile() to override DEFAULT_LINE_LIMIT at runtime - Adds resolveLineLimit() helper: -1 = default (2000), 0 = no limit (read entire file), positive = custom limit - Adds tests for resolveLineLimit and createReadFileTool options Fixes #11754
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.
This PR attempts to address Issue #11754.
Problem
The
maxReadFileLinesetting existed as a type definition and in the webview default state, but was never actually wired into theReadFileToolor the tool description. The tool always used the hardcodedDEFAULT_LINE_LIMITof 2000 lines regardless of the user setting. This caused less capable models (like local llama.cpp models) to enter read loops when the tool description and truncation messages instructed them to use chunked reading.Changes
packages/types/src/global-settings.ts: AddedmaxReadFileLineto theglobalSettingsSchemaso it flows throughRooCodeSettingssrc/core/webview/ClineProvider.ts: AddedmaxReadFileLinetogetState()andloadSettingsFromProfile()so it is available in the state pipelinesrc/core/prompts/tools/native-tools/read_file.ts: AddedmaxReadFileLinetoReadFileToolOptionsand updatedcreateReadFileTool()to reflect the actual limit in the tool descriptionsrc/core/prompts/tools/native-tools/index.ts: AddedmaxReadFileLinetoNativeToolsOptionsand passes it through tocreateReadFileTool()src/core/task/build-tools.ts: AddedmaxReadFileLinetoBuildToolsOptionsand passes it through togetNativeTools()src/core/task/Task.ts: Passesstate?.maxReadFileLineat all 4 call sites ofbuildNativeToolsArrayWithRestrictions()src/core/tools/ReadFileTool.ts: AddedresolveLineLimit()helper and uses the effective limit in both the new and legacy read pathsSemantics
maxReadFileLine = -1(default): UsesDEFAULT_LINE_LIMIT(2000 lines)maxReadFileLine = 0: No limit -- reads the entire filemaxReadFileLine > 0: Uses that value as the line limitTests
resolveLineLimit.spec.tswith 6 test casesread_file.spec.tsforcreateReadFileToolwithmaxReadFileLineoptionsFeedback and guidance are welcome.
Interactively review PR in Roo Code Cloud