Maximum tool nesting depth update this morning

Hi there!

We noticed this morning, around 7:16 AM (UTC) our gemini requests started failing with a bad request error and this body:

[
    {
        "error": {
            "code": 400,
            "message": "FunctionDeclaration 'TOOL NAME' in the request exceeds the maximum allowed nesting depth.",
            "status": "INVALID_ARGUMENT"
        }
    }
]

Here’s a request that reproduces the error:

{
    "model": "gemini-2.5-pro",
    "messages": [
        {
            "content": "you are a helpful assistant",
            "role": "system"
        },
        {
            "role": "user",
            "content": "test tool"
        }
    ],
    "temperature": 0.1,
    "tools": [
        {
            "function": {
                "description": "",
                "name": "TestToolCall",
                "parameters": {
                    "user": {
                        "type": "object",
                        "properties": {
                            "data": {
                                "type": "object",
                                "properties": {
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "itemName": {
                                                "type": "object",
                                                "properties": {
                                                    "actualName": {
                                                        "type": "string"
                                                    }
                                                },
                                                "required": [
                                                    "actualName"
                                                ]
                                            }
                                        },
                                        "required": [
                                            "itemName"
                                        ]
                                    }
                                },
                                "required": [
                                    "items"
                                ]
                            }
                        },
                        "required": [
                            "data"
                        ]
                    }
                }
            },
            "type": "function"
        }
    ],
    "max_tokens": 500,
    "stream": false
}

It seems that the maximum level of nesting is now 4, but was this change intended? We were caught off-guard this weekend with the alerts going off.

1 Like

Hello, we are experiencing this same issue, when integrating with one custom MCP server. The only difference is that one of the levels is an array (in the tool’s parameter definition)

We are using “@google/genai”: “1.23.0”

Any update on this?

@kea_andre were you able to workaround this issue ? Thanks!

I moved to vertexai, since the documentation says that’s the production-ready API