diff options
| author | Shantur Rathore <[email protected]> | 2025-12-05 19:56:56 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-05 13:56:56 -0600 |
| commit | ba417d80b1174d0e289d8fc91c77a8f6a0d592f4 (patch) | |
| tree | 70b73e67456dc478bf3dc3283f8af3e74162908c | |
| parent | 40eb8b93e132daac1dff63e260cb61a880a2ba4d (diff) | |
| download | opencode-ba417d80b1174d0e289d8fc91c77a8f6a0d592f4.tar.gz opencode-ba417d80b1174d0e289d8fc91c77a8f6a0d592f4.zip | |
tweak: bash tool improve output metadata for agent consumption, fix small timeout issue (#5131)
| -rw-r--r-- | packages/opencode/src/tool/bash.ts | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index fa737aaec..3bd1915b3 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) @@ -295,7 +297,7 @@ export const BashTool = Tool.define("bash", async () => { const timeoutTimer = setTimeout(() => { timedOut = true void killTree() - }, timeout) + }, timeout + 100) await new Promise<void>((resolve, reject) => { const cleanup = () => { @@ -320,15 +322,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) { |
