Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Grok API errors fail the run instead of completing it empty #14487

Mergedjuliusmarmingemerged 2 commits intot3code/codex-turn-mapping fromt3code/grok-prompt-error-fails-runmerged by juliusmarminge View on GitHub

juliusmarmingecommented

When Grok's API rejected a prompt (seen with an outdated CLI: 426 Upgrade Required), the thread showed an empty reply and the run was marked completed.

Grok signals a failed prompt with stopReason: "error" and puts the API message in agentResult, and this notification arrives before the session/prompt RPC error. The xAI prompt race in XAiAcpExtension.ts accepted that completion, mapped the unknown stop reason to end_turn, and then interrupted the RPC fiber that carried the real error. The adapter finalized the turn as completed with no items.

Now a completion with stopReason: "error" fails the prompt using Grok's own message (read from both _x.ai/session/prompt_complete and turn_completed.agent_result). The run then fails with a provider_error that shows the message, just as rate_limit already failed with usage_limit.

Test: a new grok_prompt_error replay fixture, recorded from real Grok 1.0.44 through a local proxy that fails only the first model request. Its messages match the incident exactly: retry_state failed, then turn_completed with stop_reason: "error", then prompt_complete, then the RPC error. The test asserts that run 1 fails with the API message and that the follow-up run completes, so the session is still usable. The fixture fails without the fix and passes with it. All Grok replays and the xAI/Grok unit tests pass.

Done by Claude Opus 5.5 in Claude Code (via T3 Code).

🤖 Generated with Claude Code


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

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

      Approvability

      Verdict: Approved at 8a01cc0

      Macroscope's review found this PR approvable — This is a narrow Grok ACP bug fix that converts an incorrectly empty successful run into a provider error while preserving follow-up prompts. The production logic is isolated and covered by a replay fixture asserting both failure reporting and session recovery.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—4.9 KiB—6.8 KiB✅
      CodexThread snapshot wire—3.7 KiB—4.9 KiB✅
      CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      CodexLive turn WebSocket decoded—20.4 KiB—29.3 KiB✅
      CodexLive turn messages—2—8✅
      ClaudeTotal thread wire—4.9 KiB—6.8 KiB✅
      ClaudeThread snapshot wire—3.7 KiB—4.9 KiB✅
      ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
      ClaudeLive turn WebSocket decoded—20.7 KiB—29.3 KiB✅
      ClaudeLive turn messages—1—8✅

      Baseline: unavailable · PR result: 8a01cc0 · 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: 106.1 KiB
      • Claude decoded thread snapshot: 106.4 KiB

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

    5. juliusmarminge merged thisf82eb0f

    6. juliusmarminge closed this

Sign in to join this conversation.