Greetings, everyone. I’m working on a project that utilizes the Vercel AI SDK, which has been very stable with tool calling using GPT-4o and the new Gemini 2 Pro experimental model. However, with Gemini-2.0-flash, I’m encountering issues where, after the message thread includes several tools cals, and particularly the same repeated tool call, the flash model starts to output markdown python code (see below) instead of actually calling the tool. Reprompting it sometimes makes it call the tool, but the issue tends to worsen as the thread grows. I’m trying to determine if this is a problem with the model itself or if it’s an issue with accessing GenAI via the Vercel SDK, as opposed to using the Google Node library. If you are experiencing this with other libraries or have insights on how to resolve this, your input would be greatly appreciated.
Example Response
I have opened the homepage in a new window. Now I need to extract all URLs in the navigation at the top. I will get the HTML of the page.
I’m having the same issue. It’s not related to Vercel AI SDK, since I’m just making HTTP requests to the API and getting the same response sometimes. It looks like a model’s issue. Have you found a workaround for this?
We see the same thing. Temporary work around we are using is to filter these out using regexp. String.replace(response, ~r/tool[\w]*[\s\S]*?/m, “”) this is elixir code. but you get the idea
Hey folks, thanks for flagging this! Just to confirm, what models are you seeing this behavior with? Is it mainly with 2.0 Flash, or with other models, too?
I have really only encountered it on flash 2.0, 1.5 pro seems fine and I wasn’t have issues with 2.0 pro experimental though I have not used it heavliy.
In our implementation this happens constantly, even when the thread isnt all that long. it will even begin to hallucinate tools that don’t exist and/or that it does not have access to. It happens frequently when the model has no tools available to it, but it can “see” tools were called in the past. We filter these out and retry, which sometimes works.
I would be happy to provide any reproductions you need, although not entirely sure how to do that. I would even be happy to jump on a zoom.
Hi Vishal, we are experiencing multiple tool calls of the same tool, even tho tool is being already called, specially with 2.5 Pro, can you help us with this?
Hey Gauransh, can you retry with the model we released today gemini-2.5-pro-preview-05-06? The new model is much better at function calling, so I’d be curious to hear if it resolves your issue
I was running into this a bunch with gemini-2.5-pro-preview-03-25, seems to also happen with gemini-2.5-pro-preview-05-06 also. Hard to say if it is more or less frequent - sometimes on the old one it was happening 20%+ of the time, others closer to 1%, but definitely got worse over the past few days.