fix(xai): emit tool-result for all provider-executed tools in Responses stream#13220
Open
giulio-leone wants to merge 1 commit intovercel:mainfrom
Open
fix(xai): emit tool-result for all provider-executed tools in Responses stream#13220giulio-leone wants to merge 1 commit intovercel:mainfrom
giulio-leone wants to merge 1 commit intovercel:mainfrom
Conversation
…es stream Provider-executed tools like web_search, x_search, and code_execution never emitted tool-result chunks on completion, causing UIs to stay stuck on "in progress" state. Follow the existing file_search_call pattern to emit tool-result with providerExecuted: true for all provider-executed tool types. Fixes vercel#13218
1 task
Author
|
Friendly ping — CI is green, tests pass, rebased on latest main. Ready for review whenever convenient. Happy to address any feedback. 🙏 |
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.
Summary
Fixes #13218 — Provider-executed tools (web_search, x_search, code_execution, etc.) in the xAI Responses API never emit
tool-resultwhen they complete, so UIs stay stuck on the 'in progress' state.Root Cause
The
doStreamhandler forresponse.output_item.doneonly emitstool-resultforfile_search_callbut skips all other provider-executed tool types (web_search_call,x_search_call,code_interpreter_call,code_execution_call,view_image_call,view_x_video_call,custom_tool_call,mcp_call).Similarly, the non-streaming
doGeneratehandler pushestool-callbut nottool-resultfor these tool types.Fix
Extended both streaming and non-streaming handlers to emit
tool-resultfor all provider-executed tool types, following the same pattern already used forfile_search_call.Streaming (
doStream): Addedtool-resultemission onresponse.output_item.doneevents for all provider-executed tool types in the shared handler block.Non-streaming (
doGenerate): Addedtool-resultpush aftertool-callfor all provider-executed tool types.Testing
doGeneratetests to verifytool-resultis now emitted alongsidetool-callfor provider-executed toolstool-resultentriesshould stream web_search tool call and result— verifiestool-resultonresponse.output_item.doneshould stream code_execution tool call and result— verifiestool-resultfor code_execution_callshould stream custom_tool_call and result— verifiestool-resultfor custom_tool_call (used by x_search sub-tools)