Skip to content

fix(grok): failed Grok text generation explains usage limit, sign-in, and model errors - #29800

Open
saphid wants to merge 7 commits into
pingdotgg:mainfrom
saphid:fix/grok-text-generation-error-detail
Open

saphid wants to merge 7 commits into
pingdotgg:mainfrom
saphid:fix/grok-text-generation-error-detail

Conversation

@saphid

@saphid saphid commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When Grok writes commit messages, PR text, branch names, or thread titles and its ACP request fails, the error only says Text generation failed in <operation>: Grok ACP request failed. Users can't tell whether to wait, sign in again, or pick another model. The same happens when switching to the selected model fails: Failed to set Grok ACP base model for text generation.

Change

Text generation now maps the ACP JSON-RPC error code to fixed details:

ACP error code Detail
-32003 (xAI rate limited, xAiRateLimitedErrorCode, the code the Grok adapter already classifies as usage_limit) Grok usage limit reached. Try again later.
-32000 (ACP authRequired) Grok authentication is required.
-32602 (invalid params), model switch only Grok rejected the text generation model settings.
anything else the existing generic detail

Grok's raw error text stays only in cause. It never goes into detail or the message. This follows the "Errors" section of docs/internals/effect-services.md: messages are fixed or built from structured attributes, never from provider text.

Scope and approval

Very small, focused fix for an obvious bug, so no prior issue: one file's two mapErrors, which threw away a structured signal the error already carries. The first version of this PR copied Grok's raw message into the detail, which goes against the rule above. That was reworked to the code mapping above (thanks @maria-rcks).

Verification

  • GrokTextGeneration.test.ts: the mock agent fails session/prompt with a 4 KB private payload. Codes -32003 and -32000 give their fixed details, -32603 and -32602 give Grok ACP request failed., and cause keeps the code and the full payload. The detail is asserted exactly (toBe), so raw text there would fail the test. A model-switch case asserts that Unknown Grok model (-32602) shows the fixed model-settings detail and that the provider text stays only in cause.
  • CI is green at 64489be.
  • Not checked: a live Grok account that hits a real usage limit.

Created with Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 3, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Nov 3, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 879b759

Macroscope's review found this PR approvable — Grok text-generation errors now explain usage limits, authentication requirements, and rejected model settings using fixed messages. The change preserves existing request behavior and does not newly expose raw provider text in error details.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The Grok provider maps selected ACP errors to specific details for rate limits, authentication failures, and rejected model settings. The mock agent can return configured prompt errors, and tests verify mapped details and preserved error causes.

Changes: Grok ACP error details

Layer / File(s) Summary
Map ACP errors
packages/provider-grok/src/server/textGeneration.ts
The provider maps rate-limit, authentication, and invalid-settings ACP errors to specific details for model-selection and general request failures. Other errors retain fallback details.
Exercise ACP error details
apps/server/src/provider/testFixtures/grok-text-mock-agent.mjs, apps/server/src/textGeneration/GrokTextGeneration.test.ts
The mock agent can return a configured JSON-RPC error for prompt requests. Tests check mapped details and verify that causes retain provider error codes and messages.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 879b7

Grok text-generation failures now show clear fixed messages for usage limits, authentication, and rejected model settings, and the raw provider text stays out of the user-facing detail. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: failed Grok text generation now gives specific messages for usage limit, sign-in, and model errors. It follows the conventional commit format and matches the changeset…
Description check Passed The description covers the problem, the change, scope, and verification, so it follows the repository template. It explains the ACP code mapping, the fixed details, and why raw provider text stays in …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: failed Grok text generation now gives specific messages for usage limit, sign-in, and model errors. It follows the conventional commit format and matches the changeset, which maps ACP codes -32003, -32000, and -32602 to fixed details. The objectives also describe a test-focused commit, but the title still reflects the behavior change.

Full details: Description check

Explanation

The description covers the problem, the change, scope, and verification, so it follows the repository template. It explains the ACP code mapping, the fixed details, and why raw provider text stays in cause. It also links the docs rule it follows and reports the tests and CI result. It does not check a live Grok usage-limit case, and it says so. The Scope section has no linked issue, but it gives a reason for omitting one, as the template allows. The Verification section names the model used, as the template asks.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 64489be and 879b759.

Files selected for processing: 2

  • apps/server/src/textGeneration/GrokTextGeneration.test.ts
  • packages/provider-grok/src/server/textGeneration.ts

Limit details: You’ve used all 10 included reviews currently available.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

…rror message

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Nov 3, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Nov 3, 2026

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

@macroscopeapp
macroscopeapp Bot dismissed their stale review November 3, 2026 02:01

Dismissing prior approval to re-evaluate 64489be

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Nov 3, 2026
@saphid saphid changed the title fix(grok): failed Grok text generation shows Grok's error message fix(grok): failed Grok text generation explains usage limit, sign-in, and model errors Nov 3, 2026
@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 14, 2026
juliusmarminge and others added 2 commits November 14, 2026 15:08
@macroscopeapp
macroscopeapp Bot dismissed their stale review November 14, 2026 15:11

Dismissing prior approval to re-evaluate 879b759

@juliusmarminge juliusmarminge added takeover:needs-julius Takeover done; route gate says Julius decides and removed takeover:in-progress A takeover lead is working on this PR labels Nov 14, 2026

This branch has not been deployed

No deployments
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). takeover:needs-julius Takeover done; route gate says Julius decides vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants