Skip to content

fix: wire up maxReadFileLine setting to ReadFileTool#11755

Draft
roomote[bot] wants to merge 1 commit intomainfrom
fix/wire-up-maxReadFileLine-setting
Draft

fix: wire up maxReadFileLine setting to ReadFileTool#11755
roomote[bot] wants to merge 1 commit intomainfrom
fix/wire-up-maxReadFileLine-setting

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 26, 2026

This PR attempts to address Issue #11754.

Problem

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 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: Added maxReadFileLine to the globalSettingsSchema so it flows through RooCodeSettings
  • src/core/webview/ClineProvider.ts: Added maxReadFileLine to getState() and loadSettingsFromProfile() so it is available in the state pipeline
  • src/core/prompts/tools/native-tools/read_file.ts: Added maxReadFileLine to ReadFileToolOptions and updated createReadFileTool() to reflect the actual limit in the tool description
  • src/core/prompts/tools/native-tools/index.ts: Added maxReadFileLine to NativeToolsOptions and passes it through to createReadFileTool()
  • src/core/task/build-tools.ts: Added maxReadFileLine to BuildToolsOptions and passes it through to getNativeTools()
  • src/core/task/Task.ts: Passes state?.maxReadFileLine at all 4 call sites of buildNativeToolsArrayWithRestrictions()
  • src/core/tools/ReadFileTool.ts: Added resolveLineLimit() helper and uses the effective limit in both the new and legacy read paths

Semantics

  • maxReadFileLine = -1 (default): Uses DEFAULT_LINE_LIMIT (2000 lines)
  • maxReadFileLine = 0: No limit -- reads the entire file
  • maxReadFileLine > 0: Uses that value as the line limit

Tests

  • Added resolveLineLimit.spec.ts with 6 test cases
  • Added read_file.spec.ts for createReadFileTool with maxReadFileLine options
  • All 45 tests pass (33 existing + 12 new)

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant