You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(EXT-617): Refactor read_file tool with pagination and bounded reads
BREAKING CHANGE: Complete rewrite of read_file tool API
Changes:
- New input schema: single file with offset/limit pagination
- Output now returns structured JSON with metadata
- Line numbering uses cat -n style (right-aligned, stable)
- Default 2000 line limit per call with pagination via next_offset
- Removed multi-file reads (now single file per call)
- Removed user approval workflow (direct execution)
- Removed image processing (to be added back in follow-up)
This implements the spec from Linear issue EXT-617 for line-based
pagination, reliable continuation via offset/limit, and bounded
output for context budget management.
Note: This is a work-in-progress draft. Tests and additional features
need to be updated/added:
- All existing tests need rewrite (300+ references to old API)
- Image handling needs to be re-implemented
- UI approval workflow needs removal
- Binary file handling (PDF/DOCX) needs re-implementation
return`Supports text extraction from PDF and DOCX files. Automatically processes and returns image files (PNG, JPG, JPEG, GIF, BMP, SVG, WEBP, ICO, AVIF) for visual analysis. May not handle other binary files properly.`
12
-
}
13
-
return`Supports text extraction from PDF and DOCX files, but may not handle other binary files properly.`
14
-
}
15
-
16
-
/**
17
-
* Options for creating the read_file tool definition.
18
-
*/
19
-
exportinterfaceReadFileToolOptions{
20
-
/** Whether to include line_ranges parameter (default: true) */
21
-
partialReadsEnabled?: boolean
22
-
/** Maximum number of files that can be read in a single request (default: 5) */
23
-
maxConcurrentFileReads?: number
24
-
/** Whether the model supports image processing (default: false) */
25
-
supportsImages?: boolean
26
-
}
27
-
28
-
/**
29
-
* Creates the read_file tool definition, optionally including line_ranges support
30
-
* based on whether partial reads are enabled.
6
+
* Single-file reads with line-based pagination, stable line numbering,
7
+
* and bounded output to stay within context budgets.
31
8
*
32
-
* @param options - Configuration options for the tool
constdescription=`Request to read a file with line-based pagination. Returns at most 2000 lines per call (configurable via limit parameter). Use offset parameter to read subsequent chunks.
38
13
39
-
// Build description intro with concurrent reads limit message
40
-
constdescriptionIntro=isMultipleReadsEnabled
41
-
? `Read one or more files and return their contents with line numbers for diffing or discussion. IMPORTANT: You can read a maximum of ${maxConcurrentFileReads} files in a single request. If you need to read more files, use multiple sequential read_file requests. `
42
-
: "Read a file and return its contents with line numbers for diffing or discussion. IMPORTANT: Multiple file reads are currently disabled. You can only read one file at a time. "
14
+
Path Resolution and Sandbox:
15
+
- file_path is required and must be relative to workspace root
16
+
- Paths are resolved to absolute and canonicalized
17
+
- Access is restricted to workspace root (sandbox enforcement)
description: "Path to the file to read, relative to the workspace",
74
-
},
75
-
}
76
-
77
-
// Only include line_ranges if partial reads are enabled
78
-
if(partialReadsEnabled){
79
-
fileProperties.line_ranges={
80
-
type: ["array","null"],
81
-
description:
82
-
"Optional line ranges to read. Each range is a [start, end] tuple with 1-based inclusive line numbers. Use multiple ranges for non-contiguous sections.",
83
-
items: {
84
-
type: "array",
85
-
items: {type: "integer"},
86
-
minItems: 2,
87
-
maxItems: 2,
88
-
},
89
-
}
90
-
}
91
-
92
-
// When using strict mode, ALL properties must be in the required array
93
-
// Optional properties are handled by having type: ["...", "null"]
0 commit comments