Open mfclarke-cnx opened 1 month ago
It looks like this hardcoded "true" is where the error is happening.
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:
Currently not implemented in streamUI:
ah this is the culprit of my issue! been doing this since v3.1.25
@mfclarke-cnx can you change this to a bug instead of enhancement?
@camwest unfortunately I don't have permissions to change the labels. @lgrammel would you be able to update labels please?
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 .done
until all tool calls complete.
I think my expectation is that the UI will be added to as the final tool calls stream in.
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
.done
until all tool calls complete.
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?
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: