Skip to content

fix(server): show Grok usage limit errors - #6396

Open
SunkenInTime wants to merge 1 commit into
pingdotgg:mainfrom
SunkenInTime:t3code/show-grok-limit-errors
Open

fix(server): show Grok usage limit errors#6396
SunkenInTime wants to merge 1 commit into
pingdotgg:mainfrom
SunkenInTime:t3code/show-grok-limit-errors

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Aug 12, 2026

Copy link
Copy Markdown

What Changed

  • treat xAI rate_limit and error prompt completions as failed ACP requests instead of successful fallback completions
  • emit one failed terminal turn, restore the Grok session to ready, and retain the selected model
  • cover the private xAI notification and full Grok adapter flow with a focused ACP mock

Why

Grok reports usage exhaustion through its private _x.ai/session/prompt_complete notification before the standard prompt request settles. T3 raced that notification against the prompt RPC, normalized the unknown rate_limit stop reason to end_turn, and cancelled the real error path. The thread therefore appeared to complete with no response or visible explanation.

The fallback now preserves failure semantics at the xAI adapter boundary and surfaces a stable, provider-specific message without synthesizing or clearing any model selection.

UI Changes

Before, a Grok usage limit could leave an empty completed turn with no error. After, the thread fails once with a visible usage-limit message while the selected Grok model remains in the composer.

Grok usage limit shown in the T3 chat surface

Verification

  • vp test run apps/server/src/provider/acp/XAiAcpExtension.test.ts apps/server/src/provider/Layers/GrokAdapter.test.ts (32 tests passed)
  • vp run --filter ./apps/server typecheck
  • targeted vp fmt --check and vp lint for all changed files
  • full Computer Use verification in Safari against an isolated T3 environment and an exact rate_limit ACP mock: the thread entered Failed, displayed the error once, returned the session to ready, and kept Grok Build selected

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included screenshot evidence for the user-visible behavior
  • No animation or timing behavior changed, so a video is not applicable

Implemented with gpt-5.6-sol through the Codex harness in T3 Code.

Note

Show Grok usage limit errors when xAI rate limit is reached

  • Adds a settleXAiPromptCompletion helper in XAiAcpExtension.ts that inspects the stopReason from xAI prompt completions and fails the pending Deferred with an AcpRequestError (code -32003, message "Grok usage limit reached. Try again later.") when stopReason is rate_limit.
  • Previously, all prompt completions resolved successfully regardless of stop reason; now rate_limit and error stop reasons produce typed failures that propagate to the adapter layer.
  • Adds a mock flag T3_ACP_EMIT_XAI_RATE_LIMIT_THEN_HANG to acp-mock-agent.ts for local testing of rate-limit behavior.

Macroscope summarized 360e13f.


Note

Medium Risk
Changes Grok/xAI prompt settlement semantics for rate_limit and error completions; incorrect handling could mis-report failures or break hung-prompt fallback, but scope is limited to the xAI ACP extension with targeted tests.

Overview
Grok usage limits and xAI prompt errors now fail the turn instead of looking like a silent success.

When _x.ai/session/prompt_complete arrives with stopReason rate_limit or error, XAiAcpExtension resolves the pending prompt via new settleXAiPromptCompletion by failing the deferred with AcpRequestError (usage limit uses code -32003 and "Grok usage limit reached. Try again later."; generic errors use agentResult when present). Pending completions are typed to allow failure, so this no longer races into a fake successful end_turn completion.

The ACP mock adds T3_ACP_EMIT_XAI_RATE_LIMIT_THEN_HANG to simulate rate-limit-then-hang behavior. Tests cover the xAI extension and full Grok adapter path: failed turn, session back to ready, and selected model unchanged.

Reviewed by Cursor Bugbot for commit 360e13f. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

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: 998c14cd-0660-4c7a-9f1a-cc65b204f8af

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.

@SunkenInTime
SunkenInTime marked this pull request as ready for review August 12, 2026 23:31
@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 360e13f

Straightforward bug fix that surfaces rate limit errors from Grok to users with a clear error message. Limited scope (error handling only), clear intent, and comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant