# X_AI_PROVIDER_UNEXPECTED

## Means

a provider ended a turn with an unknown reason and an incomplete answer

## Typical cause

a chat-completions endpoint finished a turn with a `finish_reason` this build does not know and the answer is not whole (a tool call whose arguments do not parse), or the reason was `error`. Not truncation and not a transport failure: the endpoint answered and billed, and `meta.billed` carries the usage and cost; `meta.reason` is the raw reason

## Fix

`x doctor --json`, then check what the endpoint means by the reason: a truncation needs a higher `maxTokens:` on the declaration

[MCP and AI](/error-codes#mcp-and-ai)
