From 845be553f76e1877ad1f974357264947faec2b8a Mon Sep 17 00:00:00 2001 From: chorus-codes <280607145+chorus-codes@users.noreply.github.com> Date: Wed, 27 May 2026 17:14:49 +1000 Subject: [PATCH] fix(mcp): drop redundant events[] from wait_for_chat response The handler captured every progress event into an array and embedded the whole thing into the tool result. An 8-reviewer chat routinely hit 50KB+, exceeding the MCP client's per-result token budget and forcing the client to spill to file + chunked re-read. The events are already streamed live via notifications/progress, so the embedded copy was pure duplication. Replace with eventCount for debug. Closes the long-standing "wait_for_chat results spill to file" issue noted in reference_chorus_mcp_result_parsing memory. --- src/mcp/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mcp/index.ts b/src/mcp/index.ts index e9bc4e1..a05f210 100644 --- a/src/mcp/index.ts +++ b/src/mcp/index.ts @@ -141,9 +141,16 @@ mcpServer.registerTool( void sendProgress(msg); }); + // Do NOT embed `progressEvents` in the response. Every event was + // already streamed live via `notifications/progress` (see sendProgress + // above); duplicating them here only inflates the tool result. + // An 8-reviewer chat routinely produced 50KB+ payloads that exceeded + // the MCP client's per-result token budget — the client then spills + // the whole blob to a file and forces a chunked re-read. `eventCount` + // gives callers the cardinality for debug without the bloat. const response = { ...(result as Record), - events: progressEvents, + eventCount: progressEvents.length, }; return {