Skip to content

Commit 4e6b7a6

Browse files
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 anomalyco#13146
1 parent 0bbf26a commit 4e6b7a6

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎packages/opencode/src/tool/bash.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ export const BashTool = Tool.define("bash", async () => {
7373
.string()
7474
.describe(
7575
"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'",
76-
),
76+
)
77+
.optional(),
7778
}),
7879
async execute(params, ctx) {
80+
const description = params.description ?? params.command
7981
const cwd = params.workdir || Instance.directory
8082
if (params.timeout !== undefined && params.timeout < 0) {
8183
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 () => {
182184
ctx.metadata({
183185
metadata: {
184186
output: "",
185-
description: params.description,
187+
description: description,
186188
},
187189
})
188190

@@ -192,7 +194,7 @@ export const BashTool = Tool.define("bash", async () => {
192194
metadata: {
193195
// truncate the metadata to avoid GIANT blobs of data (has nothing to do w/ what agent can access)
194196
output: output.length > MAX_METADATA_LENGTH ? output.slice(0, MAX_METADATA_LENGTH) + "\n\n..." : output,
195-
description: params.description,
197+
description: description,
196198
},
197199
})
198200
}
@@ -257,11 +259,11 @@ export const BashTool = Tool.define("bash", async () => {
257259
}
258260

259261
return {
260-
title: params.description,
262+
title: description,
261263
metadata: {
262264
output: output.length > MAX_METADATA_LENGTH ? output.slice(0, MAX_METADATA_LENGTH) + "\n\n..." : output,
263265
exit: proc.exitCode,
264-
description: params.description,
266+
description: description,
265267
},
266268
output,
267269
}

0 commit comments

Comments
 (0)