-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix multiple parallel tool call support in streamUI #1894
Comments
It looks like this hardcoded "true" is where the error is happening. ai/packages/core/rsc/stream-ui/stream-ui.tsx Line 303 in f7002ad
It's a bad assumption. The tool-call event doesn't immediately mean it's the last render call because there may be multiple tool-call events. |
A potential fix would be to add a 'all-tool-calls-done' event which gets pushed to stream after the loop right around here: Then we handle that in stream-ui and finalize the stream there. The challenge is we'd have to update anything that implements LanguageModelV1 to trigger this event, or version to V2. |
Another option is to close the stream on finish: ai/packages/openai/src/openai-chat-language-model.ts Lines 382 to 388 in f7002ad
Currently not implemented in streamUI: ai/packages/core/rsc/stream-ui/stream-ui.tsx Line 314 in f7002ad
|
ah this is the culprit of my issue! been doing this since |
@mfclarke-cnx can you change this to a bug instead of enhancement? |
I also have this issue but the weird thing about mine is the same tool is being called twice. |
As tagged by @bneigher, I have an approach I'm working on in #1904, but it's still a WIP. Main issue I have right now is that because we don't know how many tool calls will be made ahead of time, the parent "streamableUI" doesn't call I think my expectation is that the UI will be added to as the final tool calls stream in. |
I think you can get this information at the provider level. For example the OpenAI provider passes an array of tool_calls so you know when you're finished iterating that it's 'done' |
"Parallel support, how to resolve the 'done' error bug now." |
Maybe anybody knows how to tune the prompt so the model doesnot put number of tools to call at the same time? |
As a kind of "workaround" you can set Frustrating that this common benefit of AI tool calling is broken on Vercel AI UI :( |
Bug Description
streamUI doesn't gracefully handle multiple parallel tool calls. Currently when the model makes multiple tool calls, the tool handler gets called multiple times, but the first call to resolve closes the UI steam and the rest throw:
The text was updated successfully, but these errors were encountered: