From 02c8af1a2c2a8b9d3026e2bdd9792c82d4701739 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Fri, 5 Dec 2025 14:32:16 +0000 Subject: [PATCH 1/3] bash: make responses related to timeout and ouput limit more specific --- packages/opencode/src/tool/bash.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index fa737aaece8f..3244ab37101b 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -320,15 +320,15 @@ export const BashTool = Tool.define("bash", async () => { if (output.length > MAX_OUTPUT_LENGTH) { output = output.slice(0, MAX_OUTPUT_LENGTH) - resultMetadata.push(`Output exceeded length limit of ${MAX_OUTPUT_LENGTH} chars`) + resultMetadata.push(`bash tool truncated output as it exceeded ${MAX_OUTPUT_LENGTH} char limit`) } if (timedOut) { - resultMetadata.push(`Command terminated after exceeding timeout ${timeout} ms`) + resultMetadata.push(`bash tool terminated commmand after exceeding timeout ${timeout} ms`) } if (aborted) { - resultMetadata.push("Command aborted by user") + resultMetadata.push("User aborted the command") } if (resultMetadata.length > 1) { From e533455efba7c95de8cd8cfe98d6fcfd21c38397 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Fri, 5 Dec 2025 14:49:51 +0000 Subject: [PATCH 2/3] bash: Create timeout timer for 100ms more than specified. Stops responding to model when model starts a bash command with 60s with a timeout of 60s and we responding that command was killed due to timeout --- packages/opencode/src/tool/bash.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index 3244ab37101b..bf230050669d 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -295,7 +295,7 @@ export const BashTool = Tool.define("bash", async () => { const timeoutTimer = setTimeout(() => { timedOut = true void killTree() - }, timeout) + }, timeout + 100) await new Promise((resolve, reject) => { const cleanup = () => { From aabf178887de665118b28134d6e97e529d52d877 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Fri, 5 Dec 2025 19:33:19 +0000 Subject: [PATCH 3/3] bash: Don't collect ouput in memory when over MAX_LIMIT --- packages/opencode/src/tool/bash.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index bf230050669d..3bd1915b3978 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -234,13 +234,15 @@ export const BashTool = Tool.define("bash", async () => { }) const append = (chunk: Buffer) => { - output += chunk.toString() - ctx.metadata({ - metadata: { - output, - description: params.description, - }, - }) + if (output.length <= MAX_OUTPUT_LENGTH) { + output += chunk.toString() + ctx.metadata({ + metadata: { + output, + description: params.description, + }, + }) + } } proc.stdout?.on("data", append)