fix(xai): add support for response.function_call_arguments streaming events#12456
Merged
fix(xai): add support for response.function_call_arguments streaming events#12456
Conversation
dancer
approved these changes
Feb 11, 2026
ctate
added a commit
that referenced
this pull request
Feb 11, 2026
…streaming events (#12456) Add support for `response.function_call_arguments.delta` and `response.function_call_arguments.done` streaming events in the xAI Responses API provider. Previously, xAI Grok models using function tools would fail with `AI_TypeValidationError` because these standard Responses API events were missing from the Zod schema and stream handler. This is a manual backport of #12456 to the release-v5.0 branch.
3 tasks
ctate
added a commit
that referenced
this pull request
Feb 11, 2026
This is a manual backport of #12456 to the `release-v5.0` branch. ## Summary Add support for `response.function_call_arguments.delta` and `response.function_call_arguments.done` streaming events in the xAI Responses API provider. Previously, xAI Grok models using function tools would fail with `AI_TypeValidationError` because these standard Responses API events were missing from the Zod schema and stream handler. Changes: - Added `response.function_call_arguments.delta` and `.done` to `xaiResponsesChunkSchema` - Added `ongoingToolCalls` tracking to stream arguments incrementally - Added handlers for `function_call_arguments.delta/done` and skip handlers for `custom_tool_call_input.delta/done` - Refactored `function_call` handling to emit `tool-input-start` on `added` and `tool-call` on `done` ## Manual Verification - All 137 xai tests pass (node + edge) - E2E tested against real xAI API with `grok-4-1-fast-reasoning` and function tools ## Checklist - [x] Tests have been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added - [x] I have reviewed this pull request (self-review)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using xAI Grok models (e.g.
grok-4-1-fast-reasoning) with function tools via the Responses API, the model streamsresponse.function_call_arguments.deltaandresponse.function_call_arguments.doneevents — standard Responses API events also used by OpenAI. The@ai-sdk/xaiprovider's Zod schema did not include these event types, causingAI_TypeValidationErrorand breaking the entire stream whenever a function tool call was attempted.Summary
response.function_call_arguments.deltaandresponse.function_call_arguments.donetoxaiResponsesChunkSchemainxai-responses-api.tsxai-responses-language-model.tsto:output_indextool-input-startonresponse.output_item.addedforfunction_callitemstool-input-deltafor eachresponse.function_call_arguments.deltaeventtool-input-endandtool-callonresponse.output_item.done(once arguments are fully received)response.custom_tool_call_input.delta/doneevents forfunction_callitems (these are handled by the output_item events)Manual Verification
Built the patched
@ai-sdk/xailocally and ran an e2e test against the real xAI API usinggrok-4-1-fast-reasoningwith a function tool:Before fix —
AI_TypeValidationErroronresponse.function_call_arguments.done:After fix — full streaming pipeline works:
Checklist
pnpm changesetin the project root)Related Issues
Fixes function tool calls failing with
AI_TypeValidationErrorfor xAI Grok models using the Responses API.