From e5e3a6c5550c9e05d7ff201eb9116d02fd0a7366 Mon Sep 17 00:00:00 2001 From: daniel-lxs Date: Wed, 26 Nov 2025 18:40:05 -0500 Subject: [PATCH 1/3] fix: OpenRouter GPT-5 strict schema validation for read_file tool Fix read_file native tool to include line_ranges in required array when partialReadsEnabled. OpenAI strict mode requires all properties in required array (nullable ones use type: [string, null]). --- src/core/prompts/tools/native-tools/read_file.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/prompts/tools/native-tools/read_file.ts b/src/core/prompts/tools/native-tools/read_file.ts index 3a5dfd081bc..bf43f26c8af 100644 --- a/src/core/prompts/tools/native-tools/read_file.ts +++ b/src/core/prompts/tools/native-tools/read_file.ts @@ -55,6 +55,10 @@ export function createReadFileTool(partialReadsEnabled: boolean = true): OpenAI. } } + // When using strict mode, ALL properties must be in the required array + // Optional properties are handled by having type: ["...", "null"] + const fileRequiredProperties = partialReadsEnabled ? ["path", "line_ranges"] : ["path"] + return { type: "function", function: { @@ -70,7 +74,7 @@ export function createReadFileTool(partialReadsEnabled: boolean = true): OpenAI. items: { type: "object", properties: fileProperties, - required: ["path"], + required: fileRequiredProperties, additionalProperties: false, }, minItems: 1, From 84ac365a64b655f5b1de9a44b0e094fb1e20d8a2 Mon Sep 17 00:00:00 2001 From: daniel-lxs Date: Wed, 26 Nov 2025 19:05:24 -0500 Subject: [PATCH 2/3] fix: change browser_action strict mode to false and remove required action parameter --- src/core/prompts/tools/native-tools/browser_action.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/prompts/tools/native-tools/browser_action.ts b/src/core/prompts/tools/native-tools/browser_action.ts index 0a13d168f9e..5a007b9b65a 100644 --- a/src/core/prompts/tools/native-tools/browser_action.ts +++ b/src/core/prompts/tools/native-tools/browser_action.ts @@ -22,7 +22,7 @@ export default { function: { name: "browser_action", description: BROWSER_ACTION_DESCRIPTION, - strict: true, + strict: false, parameters: { type: "object", properties: { @@ -48,7 +48,6 @@ export default { description: TEXT_PARAMETER_DESCRIPTION, }, }, - required: ["action"], additionalProperties: false, }, }, From 433338d544f2011845d261447cb2c2f2baa43130 Mon Sep 17 00:00:00 2001 From: daniel-lxs Date: Wed, 26 Nov 2025 19:27:28 -0500 Subject: [PATCH 3/3] fix: ensure 'action' is a required parameter for browser_action --- src/core/prompts/tools/native-tools/browser_action.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/prompts/tools/native-tools/browser_action.ts b/src/core/prompts/tools/native-tools/browser_action.ts index 5a007b9b65a..2ff4b1cf9b8 100644 --- a/src/core/prompts/tools/native-tools/browser_action.ts +++ b/src/core/prompts/tools/native-tools/browser_action.ts @@ -48,6 +48,7 @@ export default { description: TEXT_PARAMETER_DESCRIPTION, }, }, + required: ["action"], additionalProperties: false, }, },