Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 57666f3

Browse files
committed
fix: bound accumulatedOutput growth in execute_command
Prevent unbounded memory growth during long-running commands by trimming the accumulated output buffer. The full output is preserved by the OutputInterceptor; this buffer is only used for UI display.
1 parent 2893261 commit 57666f3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/core/tools/ExecuteCommandTool.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,18 @@ export async function executeCommandInTerminal(
224224
}
225225

226226
let accumulatedOutput = ""
227+
// Bound accumulated output buffer size to prevent unbounded memory growth for long-running commands.
228+
// The interceptor preserves full output; this buffer is only for UI display.
229+
const maxAccumulatedOutputSize = terminalOutputCharacterLimit * 2
227230
const callbacks: RooTerminalCallbacks = {
228231
onLine: async (lines: string, process: RooTerminalProcess) => {
229232
accumulatedOutput += lines
230233

234+
// Trim accumulated output to prevent unbounded memory growth
235+
if (accumulatedOutput.length > maxAccumulatedOutputSize) {
236+
accumulatedOutput = accumulatedOutput.slice(-maxAccumulatedOutputSize)
237+
}
238+
231239
// Write to interceptor for persisted output
232240
interceptor?.write(lines)
233241

0 commit comments

Comments
 (0)