Gemini 2.5 Pro ending the turn when it tries calling a tool

Hi everyone,

I am running into an issue with the Gemini 2.5 Pro model. I have a tool named “code” which can be used by the model to run code in a sandbox. It seems like Gemini 2.5 Pro just ends the turn when it tries to call the tool. No errors appear - the stream just stops. I am using Vercel AI SDK.

It ends the turn without any errors and without calling the code tool:

Some interesting findings:

  1. Other tools like my ‘command’ tool consistently work for this model

  2. When the code tool is successfully called by a different model (like Claude 3.5 Sonnet) and I switch to Gemini 2.5 Pro, the model is suddenly able to consistently call the ‘code’ tool

  3. When I let Gemini 2.5 Pro call a different tool like my command tool and after that I let it call the code tool, it seems to work most of the time as well

I have no idea why this is happening as from the above findings Gemini 2.5 Pro is sometimes able to call the tool, so that should not be the issue. It can also call other tools without a problem. Other models are also able to call tools without problems.

Any ideas?

4 Likes

I am facing the same issue, at times when I execute the tool and return the result back gemini sends back an empty response and the conversation ends. Seems like this happens randomly.

1 Like

I am also facing the same issue when using the example code from Function calling with the Gemini API

From the picture (repeated call to the API) with Gemini 2.5 Pro Preview it is possible to see that the model randomly return None values instead of FunctionCall objects.

1 Like