Skip to content

gemini-3.8-flash: MALFORMED_FUNCTION_CALL when a function argument is an untyped object (repro included) #3230

Open

Description

@jordanlewis

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.

AI Studio repro link

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

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Oct 28, 2026
  2. Venkaiahbabuneelam commented on Oct 29, 2026

    @Venkaiahbabuneelam

    Hi @jordanlewis, Thank you for the detailed report and minimal reproduction!

    We were able to reproduce the FinishReason.MALFORMED_FUNCTION_CALL behavior locally on gemini-3.8-flash in AUTO mode using your create_pages schema (2/5 malformed with 'Incident Title' + maxItems: 100, and 1/5 malformed with 'IncidentTitle', while mode="ANY" succeeded 5/5).
    Since this occurs in gemini-3.8-flash's server-side AUTO function-call generation/parsing rather than client-side SDK serialization, we have escalated this internally.

    Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions