fix(provider-acp): Grok runs finish with their reply while background subagents keep working #17779
main fromrefs/pull/17779/head·opened View on GitHubGrok kept a finished root reply open until all native subagents ended. A stalled child left the thread “Working”, blocked queued messages, and turned follow-ups into interrupt-and-restart steers. Fixes #17159 and addresses the held-turn part of #15489.
Settle the root when its reply finishes. Keep each child's tools, timestamps and update throttling with the subagent, so idle routing and later turns share the same child state. Route early child frames after the Task result names their session. Stop interrupts open child tools in their own threads. Background commands and monitors retain their existing root holds. This uses the existing Grok flavor extension; other ACP flavors keep their prior behavior.
Rebuilt from the original work by @juliusmarminge in #17779, preserving its history and merging main. The child-result parsing in #21094 is complementary and remains outside this change.
Verification:
- Separate test reduction: shared adapter cases 120 → 119, declarations 116 → 114; 16 Grok replay cases retained. Replaced duplicate Stop coverage with idle/adopted cases using explicit stream milestones. Eight existing test/fixture artifacts remain; one 52-line regression was added to the existing orchestration replay module after review. No new files.
- Independent implementation rebuild removes the retained settled-root context, child-key copying and root-map exclusions. Production diff shrank from 379 to 330 changed lines, including the long-stream buffer repair.
- 346 distinct focused cases pass: 119 shared adapter, 17 Grok orchestration replays, and 210 public adapter/package cases. Scoped server, ACP and Grok typechecks, targeted lint/formatting and diff checks pass. Negative runs reproduce the held root, dropped early tools, missing Stop cleanup and leaked root tool rows.
- Two independent full-diff review rounds with Claude Opus 5.5 and Codex GPT-6-Sol. Round 1 found assistant chunks could evict an early tool call; a separate fresh test run reproduced the missing tool directly, and an independent implementation run fixed the tool-only quota. Round 2 both reviews are clean (Codex independently ran 19 focused cases; Claude ran 43).
- Current-head CI: 29 check records completed with no failed jobs; one duplicate native-fingerprint run was canceled alongside a successful same-head run. Macroscope checks are neutral and CodeRabbit is paused.
- Running Linux web app, same faithful Grok ACP peer and externally controlled gates: main's adapter leaves the returned reply running with a queued follow-up; head persists both roots completed while the child remains running. Verified idle child tools and replies, early tool frames, and Stop both idle and during a following prompt. Child tool IDs, ordinals and start times remain stable; interrupted tools stay in the child thread, with zero root tool rows. These are app commands and persisted event-driven projections, not seeded screenshots.
- Rechecked the exact repaired head in the app with 1,001 early assistant chunks followed by a child tool and more text before Task association. All chunks, tool input, eventual tool completion and child reply persisted; root completed with zero parent tool rows. Two unrelated first-run fixture failures (detached process IDs and registry transcript setup) passed focused rechecks; their original failures were retained in the verification log.
- Known existing limit: if Grok omits a child tool terminal frame even though the subagent completes, its child row remains running. Main has the same child-row behavior; its root fallback creates a separate root row. This change removes that duplicate. A tool-frame buffer above 1,000 tool frames can discard the oldest tool frame; assistant text does not consume that quota.
- Stale-steer handling, monitor/command holds and provider continuations are covered by the orchestration replays, not this browser recording. Authenticated native Grok inference was unavailable. macOS, Windows, Electron desktop, iOS and Android were not exercised. Macroscope's human-approval gate remains for this lifecycle change; no merge performed.
Before — current-main adapter, reply returned but root and queue remain held:

After — rebuilt adapter, queued follow-up completes while the child remains waiting:

Child reply after the root had completed:

Current repaired head — early child command and reply survive 1,001 assistant chunks:

Recording — queued follow-up starts before the child finishes:
Implemented with Codex GPT-6.1-Sol (high); test reduction with Codex GPT-6-Astra (high); adversarial review with Claude Opus 5.5 and Codex GPT-6-Sol, through T3 Code.
Fixes pingdotgg/t3code#17159
- 1
- 2
Pushedaa21bbc
juliusmarminge added labelstakeover:blocked
juliusmarminge removed labelstakeover:in-progress
This patch changes how the legacy Grok ACP adapter settles replies while native subagents continue. #46363 retired that integration in favor of Grok Build through the Cursor SDK, so this is no longer needed.
juliusmarminge closed this
Sign in to join this conversation.
The automated pipeline stopped on this pull request and will not merge it:
the capture step could not show the problem on the base commit, so there is nothing to prove fixed.
On both commits, enabled Grok and launched the same prompt requesting a background Task with a 180-second command and an immediate ROOT_DONE reply. Both sessions failed before inference. ROOT_DONE, queued follow-ups, child output, and Stop could not be exercised.
It stays open for a person to finish or close.