From 5bf4eec3d8ae163fcda9b5c225abd87c54bdbf9b Mon Sep 17 00:00:00 2001 From: Roo Code Date: Sun, 21 Dec 2025 16:28:23 +0000 Subject: [PATCH] feat: improve context budget truncation notice with total lines and continuation 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 --- src/core/tools/ReadFileTool.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/tools/ReadFileTool.ts b/src/core/tools/ReadFileTool.ts index 58f3cc495e..b4ee651a6d 100644 --- a/src/core/tools/ReadFileTool.ts +++ b/src/core/tools/ReadFileTool.ts @@ -547,8 +547,9 @@ export class ReadFileTool extends BaseTool<"read_file"> { content = addLineNumbers(result.content) if (!result.complete) { - // File was truncated - const notice = `File truncated: showing ${result.lineCount} lines (${result.tokenCount} tokens) due to context budget. Use line_range to read specific sections.` + // File was truncated due to context budget + const nextLine = result.lineCount + 1 + const notice = `File truncated at line ${result.lineCount} of ${totalLines} total lines due to context budget (${result.tokenCount} tokens used). To continue reading, use the read_file tool again with line_range starting at line ${nextLine} (e.g., ${nextLine}-${Math.min(nextLine + 499, totalLines)})` const lineRangeAttr = result.lineCount > 0 ? ` lines="1-${result.lineCount}"` : "" xmlInfo = result.lineCount > 0