Skip to content

Commit 120dfc7

Browse files
authored
fix(core): update read_file schema for v1 compatibility (#22183) (#26922)
1 parent c37b911 commit 120dfc7

5 files changed

Lines changed: 26 additions & 18 deletions

File tree

packages/core/src/tools/definitions/__snapshots__/coreToolsModelSnapshots.test.ts.snap

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ exports[`coreTools snapshots for specific models > Model: gemini-2.5-pro > snaps
319319
},
320320
"context": {
321321
"description": "Show this many lines of context around each match (equivalent to grep -C). Defaults to 0 if omitted.",
322+
"minimum": 0,
322323
"type": "integer",
323324
},
324325
"dir_path": {
@@ -416,15 +417,17 @@ exports[`coreTools snapshots for specific models > Model: gemini-2.5-pro > snaps
416417
"properties": {
417418
"end_line": {
418419
"description": "Optional: The 1-based line number to end reading at (inclusive).",
419-
"type": "number",
420+
"minimum": 1,
421+
"type": "integer",
420422
},
421423
"file_path": {
422424
"description": "The path to the file to read.",
423425
"type": "string",
424426
},
425427
"start_line": {
426428
"description": "Optional: The 1-based line number to start reading from.",
427-
"type": "number",
429+
"minimum": 1,
430+
"type": "integer",
428431
},
429432
},
430433
"required": [
@@ -1149,6 +1152,7 @@ exports[`coreTools snapshots for specific models > Model: gemini-3-pro-preview >
11491152
},
11501153
"context": {
11511154
"description": "Show this many lines of context around each match (equivalent to grep -C). Defaults to 0 if omitted.",
1155+
"minimum": 0,
11521156
"type": "integer",
11531157
},
11541158
"dir_path": {
@@ -1246,15 +1250,17 @@ exports[`coreTools snapshots for specific models > Model: gemini-3-pro-preview >
12461250
"properties": {
12471251
"end_line": {
12481252
"description": "Optional: The 1-based line number to end reading at (inclusive).",
1249-
"type": "number",
1253+
"minimum": 1,
1254+
"type": "integer",
12501255
},
12511256
"file_path": {
12521257
"description": "The path to the file to read.",
12531258
"type": "string",
12541259
},
12551260
"start_line": {
12561261
"description": "Optional: The 1-based line number to start reading from.",
1257-
"type": "number",
1262+
"minimum": 1,
1263+
"type": "integer",
12581264
},
12591265
},
12601266
"required": [

packages/core/src/tools/definitions/model-family-sets/default-legacy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ export const DEFAULT_LEGACY_SET: CoreToolSet = {
9797
[READ_FILE_PARAM_START_LINE]: {
9898
description:
9999
'Optional: The 1-based line number to start reading from.',
100-
type: 'number',
100+
type: 'integer',
101+
minimum: 1,
101102
},
102103
[READ_FILE_PARAM_END_LINE]: {
103104
description:
104105
'Optional: The 1-based line number to end reading at (inclusive).',
105-
type: 'number',
106+
type: 'integer',
107+
minimum: 1,
106108
},
107109
},
108110
required: [PARAM_FILE_PATH],
@@ -223,6 +225,7 @@ export const DEFAULT_LEGACY_SET: CoreToolSet = {
223225
description:
224226
'Show this many lines of context around each match (equivalent to grep -C). Defaults to 0 if omitted.',
225227
type: 'integer',
228+
minimum: 0,
226229
},
227230
[GREP_PARAM_AFTER]: {
228231
description:

packages/core/src/tools/definitions/model-family-sets/gemini-3.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ export const GEMINI_3_SET: CoreToolSet = {
106106
[READ_FILE_PARAM_START_LINE]: {
107107
description:
108108
'Optional: The 1-based line number to start reading from.',
109-
type: 'number',
109+
type: 'integer',
110+
minimum: 1,
110111
},
111112
[READ_FILE_PARAM_END_LINE]: {
112113
description:
113114
'Optional: The 1-based line number to end reading at (inclusive).',
114-
type: 'number',
115+
type: 'integer',
116+
minimum: 1,
115117
},
116118
},
117119
required: [PARAM_FILE_PATH],
@@ -230,6 +232,7 @@ export const GEMINI_3_SET: CoreToolSet = {
230232
description:
231233
'Show this many lines of context around each match (equivalent to grep -C). Defaults to 0 if omitted.',
232234
type: 'integer',
235+
minimum: 0,
233236
},
234237
[GREP_PARAM_AFTER]: {
235238
description:

packages/core/src/tools/read-file.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,20 @@ describe('ReadFileTool', () => {
148148

149149
it('should throw error if start_line is less than 1', () => {
150150
const params: ReadFileToolParams = {
151-
file_path: path.join(tempRootDir, 'test.txt'),
151+
file_path: 'test.txt',
152152
start_line: 0,
153153
};
154-
expect(() => tool.build(params)).toThrow('start_line must be at least 1');
154+
expect(() => tool.build(params)).toThrow(
155+
'params/start_line must be >= 1',
156+
);
155157
});
156158

157159
it('should throw error if end_line is less than 1', () => {
158160
const params: ReadFileToolParams = {
159-
file_path: path.join(tempRootDir, 'test.txt'),
161+
file_path: 'test.txt',
160162
end_line: 0,
161163
};
162-
expect(() => tool.build(params)).toThrow('end_line must be at least 1');
164+
expect(() => tool.build(params)).toThrow('params/end_line must be >= 1');
163165
});
164166

165167
it('should throw error if start_line is greater than end_line', () => {

packages/core/src/tools/read-file.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,6 @@ export class ReadFileTool extends BaseDeclarativeTool<
255255
return validationError;
256256
}
257257

258-
if (params.start_line !== undefined && params.start_line < 1) {
259-
return 'start_line must be at least 1';
260-
}
261-
if (params.end_line !== undefined && params.end_line < 1) {
262-
return 'end_line must be at least 1';
263-
}
264258
if (
265259
params.start_line !== undefined &&
266260
params.end_line !== undefined &&

0 commit comments

Comments
 (0)