From f1be1fcb74d58fc59d42d678cec27e0e51e4e014 Mon Sep 17 00:00:00 2001 From: grahf Date: Wed, 11 Feb 2026 06:57:11 +1100 Subject: [PATCH] fix(edit): coerce replaceAll string to boolean before execution LLMs sometimes output replaceAll as a string ("false"/"true") instead of a boolean. opencode's Go binary does strict schema validation and rejects the string type with 'expected boolean, received string'. Add pre-execution coercion in tool-execute-before, following the existing pattern used for the task tool's subagent_type. --- src/plugin/tool-execute-before.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugin/tool-execute-before.ts b/src/plugin/tool-execute-before.ts index c7fefb0a6b..34f6a15c19 100644 --- a/src/plugin/tool-execute-before.ts +++ b/src/plugin/tool-execute-before.ts @@ -39,6 +39,13 @@ export function createToolExecuteBeforeHandler(args: { } } + // Coerce string booleans for edit tool (LLMs sometimes output "false"/"true" instead of false/true) + if (input.tool === "edit") { + if (typeof output.args.replaceAll === "string") { + output.args.replaceAll = output.args.replaceAll === "true" + } + } + if (hooks.ralphLoop && input.tool === "slashcommand") { const rawCommand = typeof output.args.command === "string" ? output.args.command : undefined const command = rawCommand?.replace(/^\//, "").toLowerCase()