feat(server): show Grok subagents in the Agents panel - #6410
Conversation
Grok already emits _x.ai/session/update spawn and finish events. T3 dropped them, so children only showed up as a huge spawn_subagent tool row. Map those events to task.started and task.completed, the same fold Claude and Codex use. Hide the spawn tool so the roster is the only surface. Made with Grok 4.6.
|
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 |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
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 f3070ff. Configure here.
| ...(toolUses !== undefined ? { toolUses } : {}), | ||
| ...(durationMs !== undefined ? { durationMs } : {}), | ||
| } | ||
| : undefined; |
There was a problem hiding this comment.
Zero tokens when usage partial
Low Severity
When subagent_finished includes duration_ms or tool_calls but omits tokens_used, typedUsage is still emitted with totalTokens forced to 0. The Agents panel can then show a misleading zero-token total even though token usage was simply absent.
Reviewed by Cursor Bugbot for commit f3070ff. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces a new feature with ~200+ lines of new event handling logic for Grok subagents, emitting new task.started/task.completed events to the runtime. New capabilities with non-trivial runtime behavior changes warrant human review. You can customize Macroscope's approvability policy. Learn more. |


Grok already emits subagent spawn and finish on
_x.ai/session/update. T3 ignored them, so a 13-child session only showed fatspawn_subagenttool rows.Those events now become
task.startedandtask.completedwith role, model, duration, token count, and a truncated result. The Agents panel is the same fold Claude and Codex already use. Thespawn_subagenttool row is dropped.Stacked on #6383.
Made with Grok 4.6.
Note
Low Risk
Adapter-only event mapping with unit/integration tests; no auth or persistence changes.
Overview
Grok’s
_x.ai/session/updatesubagent_spawned and subagent_finished notifications are now handled in the Grok ACP adapter and surfaced astask.started/task.completedruntime events (same path Claude and Codex use for the Agents panel).Spawn payloads carry role, model, and description; finish payloads carry normalized status, truncated output summary, and optional usage (tokens, tool calls, duration).
spawn_subagenttool-call rows are suppressed so the UI shows agent tasks instead of bulky tool entries.Parsing and mapping live in
XAiAcpExtension; the mock ACP agent gainsT3_ACP_EMIT_XAI_SUBAGENTfor integration tests.Reviewed by Cursor Bugbot for commit f3070ff. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Show Grok subagents as task events in the Agents panel
emitGrokSubagentSessionUpdatein GrokAdapter.ts to convert xAIsubagent_spawned/subagent_finishednotifications intotask.startedandtask.completedruntime events with taskId, role, model, usage, and summary.spawn_subagenttool call events from the normal tool-call stream by tracking their IDs in a newspawnSubagentToolIdsset on the session context.GROK_SUBAGENT_TASK_TYPE,grokSubagentCompletedStatus,grokSubagentResultSummary,isGrokSpawnSubagentToolTitle) in XAiAcpExtension.ts.T3_ACP_EMIT_XAI_SUBAGENT=1flag to emit subagent lifecycle notifications for local testing.Macroscope summarized f3070ff.