-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: provider-specific file reading limits (maxReadFileLine) #11408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add a per-provider maxReadFileLine setting that allows users to override the default 2000-line limit when reading files. This helps users with slower local providers (e.g. CPU-based inference) avoid timeouts by reducing prompt size. Changes: - Add maxReadFileLine to baseProviderSettingsSchema (packages/types) - Update createReadFileTool() to reflect the effective limit in tool description - Thread the setting through getNativeTools() and buildNativeToolsArray() - Enforce the limit at execution time in ReadFileTool.processTextFile() - Apply the limit to @ mention file reads via parseMentions chain - Add MaxReadFileLineControl UI component in provider advanced settings - Add English localization keys for the new setting - Fix affected tests to account for new parameter Closes #11407
Reviewed the changes. The implementation is clean and correctly threads
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| // Clamp the limit: if the provider has a max, enforce it even when the model requests more | ||
| const requestedLimit = entry.limit ?? defaultLimit | ||
| const effectiveLimit = providerMaxReadFileLine | ||
| ? Math.min(requestedLimit, providerMaxReadFileLine) | ||
| : requestedLimit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clamping logic here (Math.min(requestedLimit, providerMaxReadFileLine)) is the core enforcement mechanism of this feature, but it has no test coverage. The test changes in this PR only add undefined to existing assertions to match the new parameter. There should be tests that verify: (1) when providerMaxReadFileLine=500 and the model requests limit=1000, the effective limit is 500, (2) when providerMaxReadFileLine is undefined, the existing DEFAULT_LINE_LIMIT behavior is preserved, and (3) the same clamping applies in both slice and indentation mode. Since processTextFile is private, these can be exercised through executeNew with a mocked task.apiConfiguration.
Fix it with Roo Code or mention @roomote and request a fix.
| showRooIgnoredFiles: boolean = false, | ||
| includeDiagnosticMessages: boolean = true, | ||
| maxDiagnosticMessages: number = 50, | ||
| maxReadFileLine?: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseMentions now has 9 positional parameters, which makes call sites fragile and hard to read (the tests that had to add undefined, // maxReadFileLine illustrate the problem). Its caller processUserContentMentions already uses a destructured options object. Consider refactoring parseMentions to accept an options object too, which would make adding future parameters straightforward and eliminate positional-ordering mistakes.
Fix it with Roo Code or mention @roomote and request a fix.
Related GitHub Issue
Closes: #11407
Description
This PR attempts to address Issue #11407 by adding a per-provider
maxReadFileLinesetting that allows users to override the default 2000-line limit when reading files. This helps users with slower local providers (e.g. CPU-based inference) avoid timeouts by reducing prompt size.Key implementation details:
Provider settings schema (
packages/types/src/provider-settings.ts): AddedmaxReadFileLine: z.number().int().min(1).optional()tobaseProviderSettingsSchema, making it available across all provider types.Tool description (
src/core/prompts/tools/native-tools/read_file.ts): UpdatedcreateReadFileTool()to accept and use the provider's effective line limit in the tool description, so the model is told about the lower limit.Tool chain (
src/core/prompts/tools/native-tools/index.ts,src/core/task/build-tools.ts): ThreadedmaxReadFileLinefromapiConfigurationthroughgetNativeTools()andbuildNativeToolsArrayWithRestrictions().Execution enforcement (
src/core/tools/ReadFileTool.ts): Both new and legacy execution paths clamp the effective limit usingMath.min(requestedLimit, providerMaxLimit), so the provider's configured limit is always respected even if the model requests more.@ mention file reads (
src/core/mentions/index.ts,src/core/mentions/processUserContentMentions.ts,src/core/task/Task.ts): ThreadedmaxReadFileLinethroughparseMentionsandprocessUserContentMentionstoextractTextFromFileWithMetadata, so mention-based file reads also respect the setting.UI (
webview-ui/src/components/settings/MaxReadFileLineControl.tsx,webview-ui/src/components/settings/ApiOptions.tsx): Added a "Max file read lines" numeric input in the provider advanced settings section, following the same pattern as existing controls likerateLimitSeconds.Test Procedure
ReadFileTooltests pass (33/33)processUserContentMentionstests pass (10/10) after updating expectations for the new parameterprovider-settingstests pass (12/12)Feedback and guidance are welcome.
Pre-Submission Checklist
Documentation Updates