Repository navigation
Description
This is a bug report regarding a reproducibly failing Gemini API request with tool calls, via the python-genai library. I cannot find any reasonable workaround and would like to bring the bug to the attention of the Gemini developers.
Model / API: gemini-3.8-flash, Gemini Developer API, function calling in AUTO mode. Reproduced both in AI Studio and through the REST API.
Symptom. The model tries to call the function, but the response ends with finishReason: MALFORMED_FUNCTION_CALL. It contains no functionCall part, and usually no text. In an agent loop this looks like the model silently stopping.
Repro. This function declaration (the original repro and an AI Studio link are below):
{
"name": "create_pages",
"description": "Create pages in Notion.",
"parameters": {
"type": "object",
"properties": {
"pages": { "type": "array", "items": { "type": "object" }, "maxItems": 100 }
}
}
}Prompt:
Invoke the tool with arguments 'Incident Title' (title), 'Impact' (select: Low/Medium/High). Add 3 rows for made-up incidents.
finishMessage from a failing response:
Malformed function call: call:default_api:create_pages{pages:[{properties:{Impact:{select:{name: High }}, Incident Title :{title:[{text:{content: Database Connection Pool Exhaustion }}]}}}, …]}
Measurements. 20 requests per row through the REST API, default settings:
| Variant | Malformed |
|---|---|
| Prompt above (key with a space) | 14/20 |
Same, but key IncidentTitle and the incident names asked to contain spaces |
8/20 |
Same as the first row, "maxItems" removed |
0/20 |
Same as the first row, items declared as `{"type": "string |
|
Same as the first row, toolConfig.functionCallingConfig.mode: "ANY" |
0/20 |
A failure where no key contains a space (second row):
Malformed function call: call:default_api:create_pages{pages:[t:{name: High }},IncidentTitle:{title:[{text:{content: PaymentGateway Timeout Error }}]}}}, …]}
Production case. We first hit this with the real Notion MCP notion-create-pages tool, whose pages[].properties is an open map keyed by datacolumn names. Removing maxItems did not fix that case. Therehe model writing those keys in quotes or backticks: theycontained spaces, colons and parentheses (e.g. date:<column>:start). We worked around it on our side by declaring free-form object parameters as JSON-encoded strings.
Expected. Either a parsed functionCall with the arguments the model produced, or a documented constraint on parameter schemas or key names that we can design around.
Activity
Venkaiahbabuneelam commentedon Oct 29, 2026
Hi @jordanlewis, Thank you for the detailed report and minimal reproduction!
We were able to reproduce the
FinishReason.MALFORMED_FUNCTION_CALLbehavior locally ongemini-3.8-flashinAUTOmode using yourcreate_pagesschema (2/5malformed with'Incident Title'+maxItems: 100, and1/5malformed with'IncidentTitle', whilemode="ANY"succeeded5/5).Since this occurs in
gemini-3.8-flash's server-sideAUTOfunction-call generation/parsing rather than client-side SDK serialization, we have escalated this internally.Thanks