vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
10.29k stars 1.55k forks source link

🐞 Model tried to call unavailable tool 'multi_tool_use.parallel' | Data stream has already been closed. #3876

Open oalexdoda opened 3 days ago

oalexdoda commented 3 days ago

Description

This is an inconsistent bug, but it triggers around 10% of the time. First, there's no error being thrown (maybe due to this https://github.com/vercel/ai/issues/3875). And if you add a console.error in that dist, here's the error being thrown server-side:

image

Code example

image

AI provider

"@ai-sdk/openai": "^1.0.4",

Additional context

It seems to happen when using a bunch of tools & streaming to useChat.

oalexdoda commented 3 days ago

I also noticed that the content comes through as empty for chats that error out, so maybe it's related to this? https://github.com/vercel/ai/issues/3263#issuecomment-2459492995

Using node v20.16.0

Edit 1: Noticed that when it errors out & you enable error streaming to the client, it throws this: Model tried to call unavailable tool 'multi_tool_use.parallel'.

I wonder if it's a tool hallucination coming from OpenAI?

Edit 2: Is there a way to turn off parallelToolCalls on streamText / useChat / result.toDataStreamResponse?

lgrammel commented 2 days ago

@oalexdoda you can turn off parallel tool calls for openai models in the model settings: https://sdk.vercel.ai/providers/ai-sdk-providers/openai#chat-models

oalexdoda commented 1 day ago

@oalexdoda you can turn off parallel tool calls for openai models in the model settings: https://sdk.vercel.ai/providers/ai-sdk-providers/openai#chat-models

Perfect, thanks @lgrammel - will try that asap.