feat(grok): add /compact slash command and compaction feedback - #5412
feat(grok): add /compact slash command and compaction feedback#5412ahmed-besic wants to merge 1 commit into
Conversation
Grok 4.5 has a large context window but quality drops well before the limit. Grok Build already supports manual /compact; T3 could send the same prompt text but never advertised the command and ignored auto_compact_completed notifications, so users got no feedback. Advertise /compact on Grok provider slash commands and map _x.ai/session_notification auto_compact_completed to thread.state.changed compacted so the existing "Context compacted" work-log row appears.
|
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 |
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature (the You can customize Macroscope's approvability policy. Learn more. |
What Changed
Grok Build already has a first-class
/compact [context]command to manually compress conversation history. T3 could technically send that text as a prompt (Grok ACP treats/compactas the compact command), but:/menu for Grok (unlike Claude provider slash commands)_x.ai/session_notificationwithauto_compact_completedand T3 ignored it — so the turn looked empty with no success feedbackThis PR:
/compacton the Grok provider snapshot as a provider slash command (Grok-only; optional note for what to preserve)x.ai/session_notification/_x.ai/session_notificationforauto_compact_completedthread.state.changed{ state: "compacted" }, which the existing ingestion path turns into the Context compacted work-log row (same UI as Claude/Codex compaction)Why
Grok 4.5’s context window is large (500k tokens), but model quality typically degrades well before that — often around the ~200k range in long agent threads. Auto-compact only kicks in near the window limit, so long productive Grok threads in T3 can get “soft-bad” (worse tool use, more drift) without an obvious way to reclaim context mid-session.
Grok Build already ships manual
/compactfor this reason. T3 should expose the same control so users can compact proactively instead of only when auto-compact finally runs (or when quality has already slipped). Showing Context compacted makes the action trustworthy — without it, sending/compactlooks like a no-op.Wire format (Grok 0.2.118 ACP): there is no working dedicated compact RPC in this version; manual compact is
session/promptwith text/compact…, thenauto_compact_completedon the session notification channel.UI Changes
/menu has no compact entry; sending/compactmay run but leaves no visible feedback./compactappears under Grok provider commands; successful compact shows the existing Context compacted work-log entry (with token before/after in event detail).No new UI components — reuses provider slash commands + context-compaction activity.
Validation
vp test apps/server/src/provider/acp/XAiAcpExtension.test.ts apps/server/src/provider/Layers/GrokProvider.test.ts apps/server/src/provider/Layers/GrokAdapter.test.ts— 38 passedsession/prompt/compactemits_x.ai/session_notificationauto_compact_completedChecklist
Made by Grok Build via the Grok Build harness while working on T3 Code.
Note
Low Risk
Additive Grok ACP extension handling and provider metadata; no auth, billing, or shared ingestion logic changes beyond wiring an existing compacted state event.
Overview
Exposes Grok’s manual
/compactflow in T3 and turns Grok’s compaction completion signal into the same Context compacted work-log feedback other providers already get.The Grok provider snapshot now advertises a
compactslash command (optional hint for what to preserve) on every probe path so it shows up in the composer/menu. On the wire,GrokAdapterlistens forx.ai/session_notification/_x.ai/session_notification, parsesauto_compact_completedvia newXAiSessionNotification/extractXAiAutoCompactCompletedhelpers, and emitsthread.state.changedwithstate: "compacted"plus token before/after (and optional summary preview)—reusing existing ingestion for the work log. The ACP mock agent simulates/compactprompts by emitting that notification; adapter and extension tests cover the mapping.Reviewed by Cursor Bugbot for commit c3b7351. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add
/compactslash command and compaction feedback to Grok providercompactslash command to the Grok provider's snapshot metadata so clients can surface it in the UI.GrokAdapterto handlex.ai/session_notificationand_x.ai/session_notificationACP events, translatingauto_compact_completednotifications intothread.state.changedevents with acompactedpayload includingtokensBefore,tokensAfter, and optionalsummaryPreview.XAiAcpExtensionwith schema validation and anextractXAiAutoCompactCompletedutility to parse and normalize compaction notification payloads./compact, enabling end-to-end integration testing.Macroscope summarized c3b7351.