Gemini 2.5-flash stuck in a tool call loop when using both tools and structured output

I’m observing rare (but deterministic) cases where gemini is “looping”: endlessly calling the same tool with the same parameters.

What I’m seeing: when providing gemini with a set of tools and asking for a structured output, sometimes gemini “loops” on one tool: it calls it, get the reponse, calls again with the same parameters, get he response, …

A few more details:

  • model: gemini 2.5-flash
  • modality: both the GenerateContent endpoint and the OpenAI-compatible chat completion endpoint
  • seed: 42, temperature: 0
  • switching off the reasoning seems to lower the occurences

I know tools + structured output was not supposed to work for gemini 2.0, but nothing is said in the doc mention a problem for 2.5. And it’s working most of the times.