Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 21, 2025

This PR attempts to address Issue #10239 (specifically the comment about semantic truncation notifications).

Problem

When files are truncated due to context budget limits, the current truncation notice says:

File truncated: showing X lines (Y tokens) due to context budget. Use line_range to read specific sections.

This notice does not include:

  1. The total number of lines in the file
  2. The next line number to continue from
  3. A concrete example of the syntax to use

This can cause models to be confused about why they received fewer lines than expected, leading to re-read attempts.

Solution

Improved the truncation notice to include all relevant information:

Before:

File truncated: showing 300 lines (1500 tokens) due to context budget. Use line_range to read specific sections.

After:

File truncated at line 300 of 2000 total lines due to context budget (1500 tokens used). To continue reading, use the read_file tool again with line_range starting at line 301 (e.g., <line_range>301-800</line_range>)

Changes

  • src/core/tools/ReadFileTool.ts - Updated the context budget truncation notice to include:
    • Total lines in the file
    • The next line number to continue from
    • A concrete example of the line_range syntax

Testing

  • All 44 existing read_file tests pass
  • TypeScript compilation passes
  • ESLint passes

Feedback and guidance are welcome!

…ontinuation example

When files are truncated due to context budget limits, the truncation notice now includes:
- Total number of lines in the file
- The next line number to continue from
- A concrete example of the line_range syntax

This helps models understand why they received fewer lines than expected and how to continue reading.

Addresses Issue #10239
@roomote
Copy link
Contributor Author

roomote bot commented Dec 21, 2025

Rooviewer Clock   See task on Roo Cloud

Reviewed the latest commit addressing @pwilkin's feedback. No issues found.

The new commit correctly updates both truncation notices with concrete line_range syntax examples:

  • maxReadFileLine === 0 case: Now shows "Showing code definitions only" with example starting from line 1
  • maxReadFileLine > 0 case: Adds nextLine calculation for continuation example
  • Tests updated to match new notice formats
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 21, 2025
@pwilkin
Copy link
Contributor

pwilkin commented Dec 21, 2025

@roomote You missed the fragment in ReadFileTool:

					if (maxReadFileLine === 0) {
						try {
							const defResult = await parseSourceCodeDefinitionsForFile(
								fullPath,
								task.rooIgnoreController,
							)
							if (defResult) {
								const notice = `Showing only ${maxReadFileLine} of ${totalLines} total lines. Use line_range if you need to read more lines`
								updateFileResult(relPath, {
									xmlContent: `<file><path>${relPath}</path>\n<list_code_definition_names>${defResult}</list_code_definition_names>\n<notice>${notice}</notice>\n</file>`,
									nativeContent: `File: ${relPath}\nCode Definitions:\n${defResult}\n\nNote: ${notice}`,
								})
							}
						} catch (error) {
							if (error instanceof Error && error.message.startsWith("Unsupported language:")) {
								console.warn(`[read_file] Warning: ${error.message}`)
							} else {
								console.error(
									`[read_file] Unhandled error: ${error instanceof Error ? error.message : String(error)}`,
								)
							}
						}
						continue
					}

that truncates due to end of definition.

@roomote
Copy link
Contributor Author

roomote bot commented Dec 21, 2025

Fixaroo Clock   See task on Roo Cloud

Fixed the reported issues. All local checks passed.

View commit | Revert commit

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