diff --git a/src/core/tools/ReadFileTool.ts b/src/core/tools/ReadFileTool.ts index b4ee651a6d..0093e89e08 100644 --- a/src/core/tools/ReadFileTool.ts +++ b/src/core/tools/ReadFileTool.ts @@ -458,7 +458,7 @@ export class ReadFileTool extends BaseTool<"read_file"> { task.rooIgnoreController, ) if (defResult) { - const notice = `Showing only ${maxReadFileLine} of ${totalLines} total lines. Use line_range if you need to read more lines` + const notice = `Showing code definitions only (0 of ${totalLines} total lines). To read file content, use the read_file tool with line_range (e.g., 1-${Math.min(500, totalLines)})` updateFileResult(relPath, { xmlContent: `${relPath}\n${defResult}\n${notice}\n`, nativeContent: `File: ${relPath}\nCode Definitions:\n${defResult}\n\nNote: ${notice}`, @@ -493,7 +493,8 @@ export class ReadFileTool extends BaseTool<"read_file"> { nativeInfo += `\nCode Definitions:\n${truncatedDefs}\n` } - const notice = `Showing only ${maxReadFileLine} of ${totalLines} total lines. Use line_range if you need to read more lines` + const nextLine = maxReadFileLine + 1 + const notice = `File truncated at line ${maxReadFileLine} of ${totalLines} total lines. To continue reading, use the read_file tool again with line_range starting at line ${nextLine} (e.g., ${nextLine}-${Math.min(nextLine + 499, totalLines)})` xmlInfo += `${notice}\n` nativeInfo += `\nNote: ${notice}` diff --git a/src/core/tools/__tests__/readFileTool.spec.ts b/src/core/tools/__tests__/readFileTool.spec.ts index d22c163636..08b0edc7ad 100644 --- a/src/core/tools/__tests__/readFileTool.spec.ts +++ b/src/core/tools/__tests__/readFileTool.spec.ts @@ -423,7 +423,7 @@ describe("read_file tool with maxReadFileLine setting", () => { expect(result).toContain(``) // Verify XML structure - expect(result).toContain("Showing only 0 of 5 total lines") + expect(result).toContain("Showing code definitions only (0 of 5 total lines)") expect(result).toContain("") expect(result).toContain("") expect(result).toContain(sourceCodeDef.trim()) @@ -450,7 +450,7 @@ describe("read_file tool with maxReadFileLine setting", () => { expect(result).toContain(`${testFilePath}`) expect(result).toContain(``) expect(result).toContain(``) - expect(result).toContain("Showing only 3 of 5 total lines") + expect(result).toContain("File truncated at line 3 of 5 total lines") }) it("should truncate code definitions when file exceeds maxReadFileLine", async () => { @@ -481,7 +481,7 @@ describe("read_file tool with maxReadFileLine setting", () => { expect(result).not.toContain("50--60 | function bar()") expect(result).not.toContain("80--90 | function baz()") - expect(result).toContain("Showing only 30 of 100 total lines") + expect(result).toContain("File truncated at line 30 of 100 total lines") }) it("should handle truncation when all definitions are beyond the line limit", async () => {