ai-sdk-provider icon indicating copy to clipboard operation
ai-sdk-provider copied to clipboard

`toolCallId` non-unique across steps when used with `ai-sdk` v5 `streamText`

Open notAunty opened this issue 4 months ago • 4 comments

As mentioned above, toolCallId is non-unique across steps when used with ai-sdk v5 streamText

toolCallId always starts with 0, causing each tool call across step to "step" on each other (pun not intended).

notAunty avatar Aug 15 '25 08:08 notAunty

+1

ghost avatar Aug 23 '25 06:08 ghost

+1

fwang2002 avatar Aug 26 '25 13:08 fwang2002

I’m also running into this issue and did some digging that might help narrow it down. It doesn’t seem to affect all models:

  • With GPT-5, tool calls get IDs like call_randomid.
  • With Gemini Flash 2.5 (google/gemini-2.5-flash), tool calls get IDs like tool_0_toolname, but the index doesn’t increment across multiple calls.

So far it looks specific to Gemini Flash 2.5 when used via the OpenRouter AI SDK provider with AI SDK v5. I haven't tested other models.

This is making it really really difficult to use the Gemini models via OpenRouter.

Seanw265 avatar Sep 13 '25 20:09 Seanw265

It seems the returned tool call id of gemini flash 2.5 has added a random number.

fwang2002 avatar Sep 16 '25 03:09 fwang2002