Problems With gemini-2.0-flash Tool Calling

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.

print(default_api.getBrowswerWindowHtml(BrowserWindowResource = "4f9608a5-55c8-457d-854d-1292b9b44010"))
3 Likes

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?

1 Like

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

1 Like

Thanks for the insight on this.