Skip to content

Commit 84bc119

Browse files
only21milclaude
andcommitted
perf(acp): project only the tail of long ACP terminal output
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8cd8056 commit 84bc119

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,10 @@ interface SnapshotMessageState {
13391339

13401340
const TOOL_UPDATE_PERSIST_EVERY = 10;
13411341

1342+
// A command row only ever shows a tail read from the last 256 KiB of its persisted
1343+
// output, so project a little more than that instead of the whole terminal buffer.
1344+
const MAX_AGENT_TERMINAL_OUTPUT_CHARS = 320 * 1024;
1345+
13421346
/**
13431347
* Some agents stream a tool's arguments (a file write's diff, `rawInput`) and
13441348
* resend the whole call each time.
@@ -4408,6 +4412,9 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
44084412
embeddedToolCallIds === undefined || embeddedToolCallIds.size === 0
44094413
? [`acp-agent-terminal:${update.terminalId}`]
44104414
: [...embeddedToolCallIds];
4415+
// Every chunk re-emits the output, so a whole long build log here grew
4416+
// serialization and the event store with the square of its length.
4417+
const output = next.output.slice(-MAX_AGENT_TERMINAL_OUTPUT_CHARS);
44114418
for (const toolCallId of projectedToolCallIds) {
44124419
const existing = context.tools.get(toolCallId);
44134420
const seeded: AcpToolCallState =
@@ -4428,7 +4435,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
44284435
status,
44294436
...(next.command === undefined ? {} : { command: next.command }),
44304437
},
4431-
next.output,
4438+
output,
44324439
),
44334440
);
44344441
}

0 commit comments

Comments
 (0)