This is definitely one of the most crazy bugs I have encountered (even as an experienced developer). I have patched in Claude from AWS and Anthropic API directly, and fixed all the nitty gritty issues that Deepseek came out of the box. But nothing can par with this level of craziness.
So we have a situation where user would choose to call a designated tool. I’ve looked up good ol’ vertex API documentation, and found that FunctionCallingMode.ANY
+ allowedFunctionNames
array will do just fine, and it’s all good to go. I had previously tested it out on some simple cases and everything looked good.
Then I got a message from my colleague saying that Gemini has generated unbelievable amount of tool calls. I was thinking, how crazy could it be? It turns out to be 24!!! I mean the historical chat messages shouldn’t even be this long. I would not have believed it if I hadn’t seen it with my own eyes. Here is the original chunk in case any Googler passes by and wants to investigate.
P.S. When is Gemini planning to roll out disabling parallel tool call and provide a tool id? I would disable it faster than Gemini finish posting a release note.
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "Elon Musk in a futuristic setting, surrounded by elements representing his various ventures like SpaceX rockets, Tesla cars, Neuralink brain interfaces, and Boring Company tunnels. The style should be dynamic and innovative, reflecting his visionary approach.",
"title": "Elon Musk Visionary",
"size": "landscape"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "A diagram illustrating Elon Musk's interconnected companies: Tesla, SpaceX, Neuralink, and The Boring Company, showing how they aim to achieve a sustainable and multi-planetary future for humanity.",
"size": "landscape",
"title": "Elon Musk's Ecosystem Diagram"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "Elon Musk standing confidently in front of a Mars colonization scene, with a SpaceX Starship in the background and a futuristic city dome. The atmosphere should be ambitious and inspiring.",
"size": "landscape",
"title": "Elon Musk Mars Vision"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk Portrait",
"prompt": "A portrait of Elon Musk with a thoughtful expression, surrounded by subtle technological elements like circuit board patterns or digital interfaces, conveying intelligence and innovation.",
"size": "portrait"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk Juggling Projects",
"size": "square",
"prompt": "A cartoon-style depiction of Elon Musk juggling multiple projects: a Tesla car, a SpaceX rocket, a Neuralink chip, and a Boring Company tunnel boring machine, emphasizing his multifaceted endeavors."
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "A stylized rendering of Elon Musk's face composed of technological elements, like wires, gears, and microchips, symbolizing his deep involvement in technology and engineering.",
"title": "Elon Musk Tech Portrait",
"size": "square"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk Superhero",
"size": "landscape",
"prompt": "Elon Musk in a superhero pose, with a cape made of solar panels and rockets, flying over a sustainable city, representing his efforts in renewable energy and space exploration."
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk Icon",
"prompt": "A minimalist icon or logo representing Elon Musk's influence, perhaps combining elements from his company logos in a sleek, modern design.",
"size": "square"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk Presenting",
"prompt": "Elon Musk giving a presentation on a stage, with a large screen behind him displaying futuristic concepts and data, capturing his role as a public visionary and innovator.",
"size": "landscape"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"size": "landscape",
"prompt": "A detailed infographic summarizing key milestones in Elon Musk's career, including founding dates of his companies, major product launches, and significant achievements.",
"title": "Elon Musk Career Infographic"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk Working",
"size": "portrait",
"prompt": "Elon Musk in a casual setting, perhaps working on a laptop or sketching ideas, conveying a sense of focused creativity and problem-solving."
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk Caricature",
"prompt": "A humorous caricature of Elon Musk with exaggerated features, perhaps riding a rocket or driving a cyber-truck, highlighting his unique personality and bold ideas.",
"size": "square"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk's Future City",
"size": "landscape",
"prompt": "A futuristic cityscape with flying Tesla vehicles and SpaceX rockets in the sky, representing the world envisioned by Elon Musk."
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk and AI",
"prompt": "Elon Musk interacting with a robot or an AI interface, symbolizing his interest in artificial intelligence and robotics.",
"size": "square"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "A timeline graphic showcasing the development and evolution of Elon Musk's major companies, from their inception to their current status.",
"size": "landscape",
"title": "Elon Musk Company Timeline"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"size": "landscape",
"prompt": "Elon Musk in a space suit, standing on Mars, looking at Earth in the distance, embodying his ultimate goal of making humanity a multi-planetary species.",
"title": "Elon Musk on Mars"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "A conceptual image of a Neuralink device being implanted, with subtle glowing lines connecting to a human brain, representing the future of brain-computer interfaces.",
"title": "Neuralink Concept",
"size": "square"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "A cutaway diagram of a Boring Company tunnel with a Tesla vehicle speeding through it, illustrating the concept of high-speed underground transportation.",
"size": "landscape",
"title": "Boring Company Tunnel Diagram"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Tesla Cybertruck Exploration",
"size": "landscape",
"prompt": "A sleek, futuristic Tesla Cybertruck driving through a barren, alien landscape, symbolizing innovation and exploration."
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"size": "landscape",
"prompt": "A SpaceX Starship launching into space from a futuristic launchpad, with dramatic smoke and fire, conveying power and ambition.",
"title": "SpaceX Starship Launch"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"title": "Elon Musk's Interests Collage",
"prompt": "A collage of images representing Elon Musk's diverse interests: space, electric vehicles, AI, and sustainable energy, showcasing his broad impact.",
"size": "landscape"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"size": "landscape",
"title": "Elon Musk Factory",
"prompt": "Elon Musk overseeing a factory floor with robots assembling Tesla vehicles, emphasizing his focus on manufacturing and automation."
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "A stylized representation of a brain with glowing neural pathways, connected to a digital interface, symbolizing Neuralink's mission.",
"title": "Neuralink Brain Interface",
"size": "square"
}
}
},
{
"functionCall": {
"name": "image_generate",
"args": {
"prompt": "A close-up of Elon Musk's eye reflecting a futuristic vision of space or technology, conveying his forward-thinking mindset.",
"size": "square",
"title": "Elon Musk Vision Eye"
}
}
}
]
},
"finishReason": "STOP",
"index": 0
}
],
"usageMetadata": {
"promptTokenCount": 12680,
"candidatesTokenCount": 952,
"totalTokenCount": 13959,
"trafficType": "ON_DEMAND",
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 10874
},
{
"modality": "IMAGE",
"tokenCount": 1806
}
],
"candidatesTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 952
}
],
"thoughtsTokenCount": 327
},
"modelVersion": "gemini-2.5-flash-preview-05-20",
"createTime": "2025-06-11T13:38:05.567023Z",
"responseId": "vYZJaO_NIorvgLUPrZ2JoAY"
}