Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 20, 2025

This PR attempts to address Issue #10239.

Summary

This PR adds line_range parameter support to simpleReadFileTool and improves truncation notices across both read file tools to provide clearer instructions for incremental file reading.

Problem

As identified in the issue, simpleReadFileTool (used by models that only support single file reads) did NOT support line ranges. This was explicitly stated in the code comments:

* This is a streamlined version of readFileTool that:
* - Does not support line ranges  // <-- The problem!

When files were truncated, the tool would suggest using line_range but the tool could not actually process that parameter, causing models to repeatedly re-read from line 1.

Changes

1. Added line_range parameter support to simpleReadFileTool

  • Added parseLineRange() helper function to parse "start-end" format
  • Added line_range to toolParamNames in src/shared/tools.ts
  • Implemented line range reading logic using the existing readLines function
  • Updated tool description in simple-read-file.ts with examples

2. Improved truncation notices

Updated truncation messages across both tools to include:

  • The exact next line number to continue from
  • A concrete syntax example for continuation

Before:

Showing only 500 of 2000 total lines. File is too large for complete display

After:

Showing lines 1-500 of 2000 total lines. To continue reading, use the read_file tool again with the line_range parameter starting at line 501 (e.g., <line_range>501-1000</line_range>)

Files Modified

  • src/core/prompts/tools/simple-read-file.ts - Updated tool description with line_range parameter
  • src/core/tools/simpleReadFileTool.ts - Added line_range parsing and handling
  • src/core/tools/ReadFileTool.ts - Improved truncation notices
  • src/shared/tools.ts - Added line_range to toolParamNames

Testing

  • TypeScript compilation passes
  • ESLint passes with no warnings
  • Related tests pass (filter-tools-for-mode.spec.ts, converters.spec.ts)

Feedback and guidance are welcome!

…tion notices

This PR addresses Issue #10239 by:

1. Adding line_range parameter support to simpleReadFileTool
   - Models using the simple read_file tool can now use <line_range>start-end</line_range>
   - Enables incremental file reading for models that previously could not continue reading truncated files

2. Improving truncation notices across both tools to include:
   - The exact next line number to continue from
   - A concrete example of the syntax to use (e.g., <line_range>501-1000</line_range>)

3. Updated tool description in simple-read-file.ts to document the new parameter

Files modified:
- src/core/prompts/tools/simple-read-file.ts
- src/core/tools/simpleReadFileTool.ts
- src/core/tools/ReadFileTool.ts
- src/shared/tools.ts (added line_range to toolParamNames)
@roomote
Copy link
Contributor Author

roomote bot commented Dec 20, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The latest commit addresses @pwilkin's feedback by always including line_range parameter documentation in the tool description regardless of the partialReadsEnabled setting. This ensures users always see how to use line ranges when truncation notices suggest using them.

Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 20, 2025
)
if (defResult) {
const notice = `Showing only ${maxReadFileLine} of ${totalLines} total lines. Use line_range if you need to read more lines`
const notice = `Showing only definitions of ${totalLines} total lines. To read actual content, use the read_file tool again with the line_range parameter (e.g., line_ranges: [[1, 500]])`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roomote Seems like you have an error in the new message here:

const notice = Showing only definitions of ${totalLines} total lines. To read actual content, use the read_file tool again with the line_range parameter (e.g., line_ranges: [[1, 500]])

@roomote
Copy link
Contributor Author

roomote bot commented Dec 20, 2025

Fixaroo Clock   See task on Roo Cloud

Fixed the parameter name inconsistency: changed "line_range parameter" to "line_ranges parameter" in all 3 truncation notice messages to match the example syntax. All local checks passed.

View commit | Revert commit

@pwilkin
Copy link
Contributor

pwilkin commented Dec 20, 2025

@roomote Also, can you please check the logic for src/core/prompts/tools/read-file.ts whether the partialReads parameter is always enabled when there is a context limit? Because another reason I can imagine this error happening is if the tool description doesn't actually mention the line_range parameter.

@roomote
Copy link
Contributor Author

roomote bot commented Dec 20, 2025

Fixaroo Clock   See task on Roo Cloud

Fixed the reported issue. The read-file.ts tool description now always includes line_range information, regardless of the partialReadsEnabled setting. This ensures models know how to continue reading truncated files even when truncation happens due to context token budget limits (not just maxReadFileLine limits). All local checks passed.

View commit | Revert commit

The tool description now always includes line_range information regardless
of the partialReadsEnabled setting. This fixes an issue where files could
be truncated due to context/token budget limits but the tool description
would not mention line_range if maxReadFileLine was set to -1 (unlimited).

This ensures models always know how to continue reading truncated files,
whether the truncation was due to line limits or context budget constraints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

4 participants