Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(grok): improve skills, plans, usage, and turn reliability #8358

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 27 commits intomain fromrefs/pull/8358/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Grok threads miss skills, reasoning controls, proposed plans, and usage data. Some turns stay on Working after ACP stops responding.

Continues #7638 by @1xpixi. The original commits and authorship are preserved, including work from @SunkenInTime, @ahmed-besic, @mbrow190, @lnieuwenhuis, and @gbarros-dev. This PR retains the original Grok changes and adds fixes found during review:

  • Keep "Always allow this session" scoped to the matching operation. A different command still asks. A changed shell-command description does not invalidate the approval.
  • Use the provider instance's environment when finding Grok plan files.
  • Fix the shared ACP parser's unchecked array access so the server typecheck passes.
  • Add focused tests and an opt-in real-Grok turn test.

Verification

  • 194 focused tests passed, including Grok, shared ACP, Cursor, and usage handling.
  • Five real CLI tests passed against Grok 1.0.5, covering authentication, model discovery, reasoning selection, and a streamed model response.
  • Real Grok adapter checks passed in a private test home: approve a command for the session, repeat it without another prompt, request approval for a different command, deny it, and capture a proposed plan without implementing it.
  • Parsed token and cost records written by the real Grok CLI.
  • Server and web typechecks passed. Changed-file lint and formatting passed.
  • Mobile typecheck reports 56 navigation errors. Clean main at d3c24a14b produces identical output. No new mobile type errors.

No live T3 state or normal Grok state was changed. Fresh browser verification and before/after captures have not been run. The screenshots below are the contributor's existing evidence from #7638, not captures of this follow-up branch.

Original UI evidence

Grok usage, from @1xpixi's Windows desktop build:

Grok Build on the Usage page

Grok reasoning control, from the same build:

Grok composer with High Effort

Model: GPT-5.6 Sol. Harness: Codex in T3 Code.


Note

Medium Risk Touches Grok turn lifecycle, permission mapping, and ACP parsing used beyond Grok; behavior changes (stall detection, rate-limit errors, session approval scoping) can affect live threads if mis-tuned.

Overview Grok integration gains skill discovery (grok inspect --json), ACP-driven reasoning effort in the model picker and per-turn session/set_model metadata, and plan mode support that surfaces plan.md writes and _x.ai/exit_plan_mode as proposed-plan events while unblocking the native approval gate.

The Grok adapter adds a turn liveness watchdog (long silence after ACP progress fails the turn; longer window while tools run; refreshes on steer, plans, approvals, and user-input), maps usage limits from xAI rate_limit completions, and improves permissions: session-scoped auto-approval by operation identity, fallback when Grok omits allow_always, and CLI argv that mirror T3 runtime modes (--permission-mode / --always-approve).

Shared ACP changes emit in-progress tool updates, bound oversized tool output (including whitespace-only buffers), and coalesce streaming command output using content length—not just detail. The mobile usage chart adds Grok as a provider band with theme-aware colors. The ACP mock agent grows scenario flags to exercise these paths in tests.

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

Note

Add Grok turn watchdog, plan mode, usage tracking, and reasoning effort

  • Adds an inactivity watchdog to GrokAdapter.ts that cancels and settles stalled ACP turns (10 min default, 30 min with active tools), with liveness tracking around approvals and user input.
  • Detects enter_plan_mode and exit_plan_mode tool calls, emits turn.proposed.completed events when Grok writes plan.md, and intercepts x.ai/exit_plan_mode to capture plan content without native gating.
  • Adds Grok Build usage support across the stack: bumps usage contract to v5 with backward-compatible merge for v4, parses updates.jsonl transcripts via parseGrokLine in usageTranscripts.ts, and adds Grok series to web and mobile usage charts.
  • Propagates per-turn reasoning effort to setSessionModel metadata in GrokAcpSupport.ts, validates tokens, and skips redundant calls.
  • Discovers Grok skills at runtime via grok inspect --json in GrokSkills.ts with a 4 s timeout and soft-fail to empty.
  • Improves tool-call update coalescing in AcpRuntimeModel.ts to emit on status changes and track combined output growth (detail/content/rawOutput) instead of detail length alone.
  • Risk: USAGE_CONTRACT_VERSION bumps from 4 to 5 in usage.ts; older clients below USAGE_MERGE_COMPATIBLE_SINCE (4) will be marked stale. selectGrokPermissionOptionId falls back to allow_once when acceptForSession is missing, changing approval behavior for sessions where Grok omits that option.
Macroscope summarized 01cc3ac.
    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: c29d928a-c7b2-41ac-8687-bc7e3fca5c02

      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

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

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

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.3 KiB13.3 KiB+20 B (+0.1%)15.1 KiB✅
      CodexThread snapshot wire6.9 KiB6.9 KiB+2 B (+0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.4 KiB+18 B (+0.3%)7.8 KiB✅
      CodexLive turn WebSocket decoded55.6 KiB55.6 KiB+44 B (+0.1%)66.4 KiB✅
      CodexLive turn messages1011+1 (+10.0%)21✅
      ClaudeTotal thread wire13.3 KiB13.3 KiB−5 B (−0.0%)15.1 KiB✅
      ClaudeThread snapshot wire6.9 KiB6.9 KiB0 B (0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.4 KiB6.4 KiB−5 B (−0.1%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded56.4 KiB56.4 KiB−44 B (−0.1%)66.4 KiB✅
      ClaudeLive turn messages1110−1 (−9.1%)21✅

      Baseline: d3c24a1 · PR result: 01cc3ac · Source CI: success

      Scenario and decoded snapshot size

      10 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.

      • Codex decoded thread snapshot: 109.4 KiB
      • Claude decoded thread snapshot: 110.1 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR adds multiple Grok capabilities and materially changes turn lifecycle, permission gating, shared ACP event handling, and usage-cost metering. Its broad runtime blast radius and substantial new logic call for human review despite the accompanying tests.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. One consistency finding on the new web usage provider entry: the Grok series color is a fixed hex that collides with the chart's own chrome color and does not follow the appearance-contrast tokens the neighbouring neutral series uses. Everything else in the web scope (UsageProviderChart.test.ts fixture, PROVIDER_PRESENTATION shape/order, GrokIcon reuse from ../Icons) is consistent with the existing registry contract.

      Posted via Macroscope — UI Consistency

Sign in to join this conversation.