Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(grok): bound cumulative tool output updates #7279

Mergedlnieuwenhuis(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/7279/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Grok's ACP CLI resends the entire accumulated terminal output on every tool_call_update notification (~10/sec, 145 KB+ per update) instead of a delta, so one redrawing terminal ballooned into tens of thousands of runtime events per turn. Because ingestion processes runtime events serially, a single busy Grok tool call head-of-line-blocked every other thread.

The shared ACP parser now bounds tool-call text output to the last 8 KB — tool call state, rawOutput, and the raw payload alike, leaving non-text content entries such as diffs and images untouched — and the ACP session runtime coalesces cumulative resends that did not grow meaningfully. Terminal (completed/failed) updates always emit immediately, so the final state of a tool call is unchanged. No timers: the emission decision is a pure function of the previous and next state.

Verification: vp test run apps/server/src/provider/acp plus the Grok and Cursor adapter/provider suites — 134 passed, 6 skipped; targeted typecheck and lint clean. A simulated 1000-update flood (31.6 MB of notifications) drops from 1000 runtime events / ~31.6 MB to 114 events / 2.51 MB, with every individual event capped at ~24.9 KB no matter how long the tool call runs, and the final detail still reflecting the last frame.

Two judgment calls worth maintainer eyes: Cursor shares this parser, so a Cursor tool call with more than 8 KB of text output now persists a marked 8 KB tail instead of the full buffer (clients already summarize or clamp what they render, and payloads under the cap are byte-identical to before); and a tool call abandoned without a terminal status can leave its last few coalesced updates unemitted (up to ~1 s stale at Grok's redraw rate) — a turn-end flush was left out of scope.

Related but not fixed here: #5681 (serial ingestion) and #6560 (backlog loss on restart). Not reproduced against a real Grok CLI; the flood is reproduced from the notification shape described in the issue.

Fixes #6556

Claude Fable 5 via Claude Code


Note

Medium Risk Shared ACP parsing affects Cursor and other providers: large tool text is truncated in stored state, and in-progress UI can lag slightly when updates are coalesced without a terminal status.

Overview Stops Grok-style ACP tool_call_update floods (full cumulative terminal output on every redraw) from overwhelming serial runtime event ingestion.

AcpRuntimeModel caps tool-call text to an 8 KB tail with [Earlier output truncated] on joined content text, matching rawOutput string fields, and rawPayload so persistence/logging cannot bypass the limit; interleaved diffs and other non-text entries stay in order. decideToolCallUpdateEmission coalesces in-progress updates unless detail grows by ≥256 chars, the title changes, 10 updates were skipped, or status is completed/failed (always emitted).

AcpSessionRuntime tracks per-tool-call emission metadata and replaces the old “emit on any detail change” rule with that decision, while still merging state so the latest snapshot is kept for the terminal emit.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4938a3c0a4adde37ccc9c3017ff578d4072b1aba. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Bound cumulative tool call output and coalesce high-frequency ToolCallUpdated events

  • Caps tool call text content at 8,000 characters using a tail-window approach, prefixing truncated output with [Earlier output truncated]. The same bounding applies to rawOutput fields (content, stdout, stderr, output) and the rawPayload attached to events.
  • Adds decideToolCallUpdateEmission in AcpRuntimeModel.ts to coalesce frequent tool_call_update notifications: terminal states always emit, updates without detail are dropped, and intermediate updates only emit on title change, ≥256 chars of growth, or after 10 skipped updates.
  • Reworks handleSessionUpdate in AcpSessionRuntime.ts to use the new coalescing logic, tracking lastEmittedDetailLength and skippedSinceEmit per tool call.
  • Behavioral Change: clients previously received every ToolCallUpdated event and unbounded content; they now receive coalesced events with content capped at 8,000 characters.
Macroscope summarized 4938a3c.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 6e338183-2feb-4216-a440-b33aec12cbc4

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved 4938a3c

      Defensive bug fix that caps oversized tool call output (8000 chars) and coalesces rapid cumulative updates from Grok's ACP CLI. Changes are self-contained to ACP provider files with comprehensive test coverage, and review comments have been addressed.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. t3dotgg(GitHub profile, opens in a new tab) added labelsvouch:trusted

    5. t3dotgg(GitHub profile, opens in a new tab) removed labelsvouch:unvouched

Sign in to join this conversation.