From 4e6b7a665b8bccc5f5d05ab4013f56390a65dda7 Mon Sep 17 00:00:00 2001 From: Daniel Cherubini Date: Fri, 20 Mar 2026 14:07:58 +0100 Subject: [PATCH] fix: make bash tool description parameter optional The description parameter on the bash tool is required but some models (especially smaller/local models) don't always include it in tool calls, causing "Invalid input: expected string, received undefined" errors that loop indefinitely. Make it optional and fall back to the command string when not provided. Fixes #13146 --- packages/opencode/src/tool/bash.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index 50ae4abac8de..916ea88d9d1b 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -73,9 +73,11 @@ export const BashTool = Tool.define("bash", async () => { .string() .describe( "Clear, concise description of what this command does in 5-10 words. Examples:\nInput: ls\nOutput: Lists files in current directory\n\nInput: git status\nOutput: Shows working tree status\n\nInput: npm install\nOutput: Installs package dependencies\n\nInput: mkdir foo\nOutput: Creates directory 'foo'", - ), + ) + .optional(), }), async execute(params, ctx) { + const description = params.description ?? params.command const cwd = params.workdir || Instance.directory if (params.timeout !== undefined && params.timeout < 0) { throw new Error(`Invalid timeout value: ${params.timeout}. Timeout must be a positive number.`) @@ -182,7 +184,7 @@ export const BashTool = Tool.define("bash", async () => { ctx.metadata({ metadata: { output: "", - description: params.description, + description: description, }, }) @@ -192,7 +194,7 @@ export const BashTool = Tool.define("bash", async () => { metadata: { // truncate the metadata to avoid GIANT blobs of data (has nothing to do w/ what agent can access) output: output.length > MAX_METADATA_LENGTH ? output.slice(0, MAX_METADATA_LENGTH) + "\n\n..." : output, - description: params.description, + description: description, }, }) } @@ -257,11 +259,11 @@ export const BashTool = Tool.define("bash", async () => { } return { - title: params.description, + title: description, metadata: { output: output.length > MAX_METADATA_LENGTH ? output.slice(0, MAX_METADATA_LENGTH) + "\n\n..." : output, exit: proc.exitCode, - description: params.description, + description: description, }, output, }