diff --git a/packages/types/src/tool-params.ts b/packages/types/src/tool-params.ts index bb408c18e3..20f2273ba1 100644 --- a/packages/types/src/tool-params.ts +++ b/packages/types/src/tool-params.ts @@ -27,6 +27,8 @@ export interface FileEntry { path: string /** 1-indexed line number to start reading from (default: 1) */ offset?: number + /** Maximum lines to return (default: value of maxReadFileLine setting) */ + limit?: number /** Reading mode: "slice" for simple reading, "indentation" for smart block extraction */ mode?: ReadMode /** Configuration for indentation mode */ diff --git a/src/core/tools/ReadFileTool.ts b/src/core/tools/ReadFileTool.ts index a7f5e4fb50..a070efc061 100644 --- a/src/core/tools/ReadFileTool.ts +++ b/src/core/tools/ReadFileTool.ts @@ -37,6 +37,7 @@ interface FileResult { notice?: string // Slice/indentation mode parameters offset?: number + limit?: number mode?: ReadMode indentation?: IndentationConfig xmlContent?: string @@ -106,6 +107,7 @@ export class ReadFileTool extends BaseTool<"read_file"> { status: "pending", // Map slice/indentation mode parameters offset: entry.offset, + limit: entry.limit, mode: entry.mode, indentation: entry.indentation, })) @@ -395,7 +397,7 @@ export class ReadFileTool extends BaseTool<"read_file"> { const result = await readFileContent({ filePath: fullPath, offset: fileResult.offset, - // limit is controlled by maxReadFileLine setting, not model input + limit: fileResult.limit, mode: fileResult.mode, indentation: fileResult.indentation, defaultLimit: maxReadFileLine > 0 ? maxReadFileLine : undefined, diff --git a/src/integrations/misc/read-file-content.ts b/src/integrations/misc/read-file-content.ts index 91fc8e22b4..52362042f2 100644 --- a/src/integrations/misc/read-file-content.ts +++ b/src/integrations/misc/read-file-content.ts @@ -452,7 +452,7 @@ export async function readIndentationBlock( hasMoreAfter: r.number < records.length, linesBeforeStart: r.number - 1, linesAfterEnd: records.length - r.number, - truncatedByLimit: true, + truncatedByLimit: records.length > finalLimit, lineLengthTruncations, }, }