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
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed