perf(server): stop shipping full MCP tool results in thread payloads - #5482
Conversation
mcp_tool_call activities bypassed payload slimming entirely, so full tool results (up to 1 MB per call) shipped in every snapshot and live event. Keep the fields the expanded-row UI renders and summarize the result like regular tool output: 12.2 MB -> 546 KB across the seeded real-data db. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 95ab949. Configure here.
The integration test asserted MCP payloads pass through verbatim; it now asserts the slimmed shape and that the expanded row's rendered fields survive on both clients. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ApprovabilityVerdict: Approved 22f7a58 Performance optimization extending existing payload slimming to MCP tool calls. The change keeps UI-rendered fields while summarizing bulky result content, with full payloads preserved in persistence. Well-tested and self-contained. You can customize Macroscope's approvability policy. Learn more. |
Merges upstream directly rather than rebuilding the provenance stack and importing a tree delta. upstream/main is append-only, so a merge is sound, and because the previous sync recorded upstream ancestry the merge base is a2ca89a -- this replays three commits, not the whole divergence: a483337 fix: respect time format for sidebar snooze (pingdotgg#4438) 1ffba70 fix(web): closed plan sidebar stays closed when returning (pingdotgg#5484) 3da315e perf(server): stop shipping full MCP tool results (pingdotgg#5482) Two resolutions. SidebarV2.tsx conflicted three ways. The import block is a union: the fork needs EnvironmentId, upstream adds TimestampFormat. The other two are useCallback dependency arrays where upstream adds updateThreadMetadata and timestampFormat; both identifiers exist in the merged file, so omitting them would leave the callbacks capturing stale values. BoardView.tsx did not conflict and still broke. pingdotgg#4438 added a timestampFormat parameter to resolveSnoozePresets and snoozeWakeDescription and updated its own call sites, but the board is fork code, so its two calls kept the old arity. Caught by typecheck, not by git. BoardView already imported useClientSettings, so the fix is the same one-line hook SidebarV2 uses. Verified: full recursive typecheck clean; apps/web 2087 tests pass. Two failures predate this merge and reproduce on fork/dev unmerged -- a Codex structured output test, and runtimeAbi.test.ts failing to transform a vendored .wasm asset. Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
## What's Changed * perf(server): stop shipping full MCP tool results in thread payloads by @t3dotgg in pingdotgg/t3code#5482 * fix(web): closed plan sidebar stays closed when returning to a thread by @t3dotgg in pingdotgg/t3code#5484 * fix: respect time format for sidebar snooze by @huxcrux in pingdotgg/t3code#4438 **Full Changelog**: pingdotgg/t3code@v0.0.32-nightly.20260806.1012...v0.0.32-nightly.20260806.1014 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.32-nightly.20260806.1014

MCP tool calls were exempt from activity payload slimming:
projectActivityPayloadearly-returns onitemType === "mcp_tool_call", so the full tool result rides along in every snapshot and live event. On MCP-heavy threads this dominates the wire — one imported thread ships 3.2 MB gzipped, with two-thirds of its post-slimming bytes being unslimmed MCP payloads (worst single call: a GitHubfetch_prresult at 1 MB).The exemption existed because both clients render
payload.data.itemin the expanded work-log row. The fix keeps exactly the fields that row renders (tool,server,status,arguments,appContext,error,durationMs, plustoolName/inputfor the Claude-adapter shape) and summarizes the result to one 84-char line, same as regular tool output. Full payloads stay in SQLite, so an on-demand detail endpoint can be added later without data loss.Measured against a real db seeded with six representative threads (2,991 MCP activities): 12.2 MB of MCP payload JSON drops to 546 KB (95.6% reduction). Both provider payload shapes (Codex
data.item, Claude/OpenCodedata.result) verified against real rows.Note: this trades away in-app access to full historical MCP results (they were previously visible in the expanded row). Per the pagination investigation, that's an accepted temporary loss; the data remains in persistence.
Change made by Claude Fable 5 via Claude Code.
Note
Medium Risk
Changes the shape and fidelity of MCP activity data on thread snapshots and live events (lossy summaries), but scope is limited to projection with strong test coverage and no persistence changes.
Overview
MCP tool calls are no longer exempt from activity payload slimming in
projectActivityPayload. Instead of passingmcp_tool_callthrough unchanged, the server now runsprojectMcpToolCallData, which keeps only fields the expanded work-log row uses (tool,server,status,arguments,appContext,error,durationMs, plus Claude-styletoolName/input) and replaces full tool results with a one-line summary via the samesummarizeToolTextOutputhelper used for other tools.Codex-shaped payloads (
data.item.result) and Claude/OpenCode-shaped payloads (data.resultblocks) are both handled; internal metadata like_metaand largestructuredContentare dropped. Changed file paths can still be collected into afilesarray. Full MCP results remain in persistence—only snapshot/live thread transports shrink.Tests now assert large MCP fixtures compress dramatically and that web/mobile derived views stay aligned except for the intentional loss of full historical MCP result text in the expanded row.
Reviewed by Cursor Bugbot for commit 22f7a58. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Stop shipping full MCP tool results in thread payloads
projectMcpToolCallDatain ActivityPayloadProjection.ts to slim MCP tool-call payloads: only whitelisted fields (tool,server,arguments, etc.) are kept, andresultcontent is replaced with a short text summary.toolName/input/result) MCP data formats.filesarray on the slimmed payload.itemType === "mcp_tool_call"previously passed through unchanged; they now return a slimmed data object, which reduces payload size significantly (tests assert < 500 bytes).Macroscope summarized 22f7a58.