fix(server): show Grok usage limit errors #6396
main fromrefs/pull/6396/head·opened View on GitHubWhat Changed#
- treat xAI
rate_limitanderrorprompt 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.

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 --checkandvp lintfor all changed files - full Computer Use verification in Safari against an isolated T3 environment and an exact
rate_limitACP mock: the thread enteredFailed, displayed the error once, returned the session to ready, and keptGrok Buildselected
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
settleXAiPromptCompletionhelper inXAiAcpExtension.tsthat inspects thestopReasonfrom xAI prompt completions and fails the pendingDeferredwith anAcpRequestError(code-32003, message "Grok usage limit reached. Try again later.") whenstopReasonisrate_limit. - Previously, all prompt completions resolved successfully regardless of stop reason; now
rate_limitanderrorstop reasons produce typed failures that propagate to the adapter layer. - Adds a mock flag
T3_ACP_EMIT_XAI_RATE_LIMIT_THEN_HANGtoacp-mock-agent.tsfor local testing of rate-limit behavior.
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.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Note
🤖 GPT-5.6 Sol responding on behalf of Theo
I am closing this because #8358 has landed in
mainand covers the same Grok usage-limit error handling. I checked the current implementation and did not find any remaining change from this PR that we still need to merge.Thank you for putting this together. The closure is only because the work is now covered elsewhere, not because there was a problem with your contribution.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
998c14cd-0660-4c7a-9f1a-cc65b204f8afYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share