Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/opencode/src/tool/bash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,24 @@ export const BashTool = Tool.define("bash", async () => {
})
})

let resultMetadata: String[] = ["<bash_metadata>"]

if (output.length > MAX_OUTPUT_LENGTH) {
output = output.slice(0, MAX_OUTPUT_LENGTH)
output += "\n\n(Output was truncated due to length limit)"
resultMetadata.push(`Output exceeded length limit of ${MAX_OUTPUT_LENGTH} chars`)
}

if (timedOut) {
output += `\n\n(Command timed out after ${timeout} ms)`
resultMetadata.push(`Command terminated after exceeding timeout ${timeout} ms`)
}

if (aborted) {
output += "\n\n(Command was aborted)"
resultMetadata.push("Command aborted by user")
}

if (resultMetadata.length > 1) {
resultMetadata.push("</bash_metadata>")
output += "\n\n" + resultMetadata.join("\n")
}

return {
Expand Down