This is a bug report regarding a reproducibly failing Gemini API request with tool calls. 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 a function with a specific nested schema, 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:[t:{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"} |
0/20 |
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:[{properties:{Impact:{select:{name: High }},IncidentTitle:{title:[{text:{content: Payment Gateway 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 database column names. Removing maxItems did not fix that case. There, finishMessage showed the model writing those keys in quotes or backticks: they contained 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.