Skip to content

Commit 6aa157c

Browse files
committed
limit bash tool to 1000 lines of output
1 parent 9fff9a3 commit 6aa157c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { Wildcard } from "../util/wildcard"
1212
import { $ } from "bun"
1313
import { Agent } from "../agent/agent"
1414

15-
const MAX_OUTPUT_LENGTH = 30000
1615
const DEFAULT_TIMEOUT = 1 * 60 * 1000
1716
const MAX_TIMEOUT = 10 * 60 * 1000
1817

@@ -107,7 +106,6 @@ export const BashTool = Tool.define("bash", {
107106
const process = exec(params.command, {
108107
cwd: app.path.cwd,
109108
signal: ctx.abort,
110-
maxBuffer: MAX_OUTPUT_LENGTH,
111109
timeout,
112110
})
113111

@@ -155,6 +153,12 @@ export const BashTool = Tool.define("bash", {
155153
},
156154
})
157155

156+
const lines = output.split("\n")
157+
if (lines.length > 1000) {
158+
output = lines.slice(0, 1000).join("\n")
159+
output += "\n\n(Ouput was truncated)"
160+
}
161+
158162
return {
159163
title: params.command,
160164
metadata: {

0 commit comments

Comments
 (0)