fix: preserve complete raw usage objects for xAI Responses (#19657)
## Background xAI Responses JSON and SSE parsing dropped provider-specific top-level and nested fields from final-step usage.raw while normalized token counts remained correct. ## Root Cause Strict Zod usage schemas stripped unknown fields before conversion to LanguageModelV4Usage; the immutable reproduction and existing provider fixtures confirmed data loss at the response parsing boundary. ## Summary Added JSON-valued catchalls to the xAI Responses usage and token-detail schemas, updated affected snapshots, and added a patch changeset for @ai-sdk/xai. ## Testing Added generate and stream response-path tests covering context details, server-side tool usage, unknown top-level and nested fields, normalized counts, last-event-wins streaming behavior, and known-field validation. ## End-to-end Validation - `replay_original_reproduction`: immutable generate/stream replay exited successfully with no bug signal. - `pnpm -C examples/ai-functions exec tsx -e "<live xAI generateText/streamText web-search probe>"`: both live paths preserved `context_details` and `server_side_tool_usage_details` in final-step `usage.raw`. ## Related Issues Fixes #19652 Closes #19656 --------- Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com> Co-authored-by: gr2m <39992+gr2m@users.noreply.github.com>
A
ai-sdk-factory[bot] committed
41e7760373f181e29202a59c12370ffaeba87f2b
Parent: 4cf7c85
Committed by GitHub <noreply@github.com>
on 8/26/2026, 3:03:57 PM