fix(server): show Grok usage limit errors - #6396
Conversation
|
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: 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. |
What Changed
rate_limitanderrorprompt completions as failed ACP requests instead of successful fallback completionsWhy
Grok reports usage exhaustion through its private
_x.ai/session/prompt_completenotification before the standard prompt request settles. T3 raced that notification against the prompt RPC, normalized the unknownrate_limitstop reason toend_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 typecheckvp fmt --checkandvp lintfor all changed filesrate_limitACP mock: the thread enteredFailed, displayed the error once, returned the session to ready, and keptGrok BuildselectedChecklist
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
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.rate_limitanderrorstop reasons produce typed failures that propagate to the adapter layer.T3_ACP_EMIT_XAI_RATE_LIMIT_THEN_HANGtoacp-mock-agent.tsfor 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_completearrives withstopReasonrate_limitorerror,XAiAcpExtensionresolves the pending prompt via newsettleXAiPromptCompletionby failing the deferred withAcpRequestError(usage limit uses code-32003and "Grok usage limit reached. Try again later."; generic errors useagentResultwhen present). Pending completions are typed to allow failure, so this no longer races into a fake successfulend_turncompletion.The ACP mock adds
T3_ACP_EMIT_XAI_RATE_LIMIT_THEN_HANGto 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.