From 738ddea06f6402ece68ec016d4b6eb6c4176e8e0 Mon Sep 17 00:00:00 2001 From: Nikita Ashikhmin Date: Wed, 7 Oct 2026 23:02:24 +0400 Subject: [PATCH] perf: yield between replayed history messages A session/load of a long history sent every update from one macrotask when the client read fast enough, starving other sessions and incoming requests. The replay now shares the consumer's 8 ms budget and yields between messages. The updates and their order are unchanged. Co-Authored-By: Claude Opus 5.5 --- src/acp-agent.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/acp-agent.ts b/src/acp-agent.ts index b6abf63b..0ce9837d 100644 --- a/src/acp-agent.ts +++ b/src/acp-agent.ts @@ -7992,6 +7992,10 @@ export class ClaudeAcpAgent { }; const replayMessage = async (message: SessionMessage): Promise => { + // A long history is sent in order, but with event-loop turns in between, + // so other sessions and incoming requests are not starved meanwhile. + const pause = messageLoopYielder.maybeYield(); + if (pause) await pause; if (pending?.stopped || isReplayHiddenMetaMessage(message)) { return; }