We’ve been testing the new gemini-2.5-pro-exp-03-25 model via the Python google-genai library and encountered an issue specifically related to function calling with complex schemas.
Scenario:
We define a function (execute_operations) with a relatively complex parameter schema (nested objects, arrays of objects with multiple properties, enums).
We use a system instruction prompting the model to generate complex, dummy data for this function call for testing purposes.
Observation:
When using gemini-2.5-pro-exp-03-25 , the API consistently returns a ServerError: 500 INTERNAL when the model attempts to generate a FunctionCall with complex arguments trying to match the schema. The specific error message is:
{'error': {'code': 500, 'message': 'An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting', 'status': 'INTERNAL'}}
Here is a colab notebook that reproduces the error: Google Colab
When using gemini-2.0-flash with the exact same code, schema, and prompt, the model successfully generates the FunctionCall with the expected complex arguments.
It seems gemini-2.5-pro-exp-03-25 can successfully call the same function if the required arguments/generated call structure is much simpler.
This suggests a potential issue specifically with gemini-2.5-pro-exp-03-25’s handling of function calling when the required arguments structure (based on the provided schema) becomes sufficiently complex.
Has anyone else experienced similar behavior with gemini-2.5-pro-exp-03-25 and complex function call schemas?
I am also experiencing issues with function calling. For example, I was trying to run this multi-agent workflow from llamaIndex using gemini 2.5 pro and it either stops prematurely after the research agent has finished its work or it gets itself in a circular reference. Using gemini flash 2.0, the workflow executes flawlessly.
Below is the code I used to integrate the gemini llm into the llamaIndex example code mentioned above. I have tried various configurations for the gemini pro llm but nothing seems to work..
def get_llm(model="gemini-2.0-flash"):
# Get credentials for Vertex AI
credentials, _ = default(scopes=["https://www.googleapis.com/auth/cloud-platform"])
auth_req = google.auth.transport.requests.Request()
credentials.refresh(auth_req)
if not credentials.valid:
raise RuntimeError("Failed to refresh Google Cloud credentials.")
# Base configuration
llm_config = {
"api_base": f"https://{region}-aiplatform.googleapis.com/v1/projects/{project_id}/locations/{region}/endpoints/openapi",
"api_type": "open_ai",
"model": model,
"temperature": 0.1,
"vertexai_config": {
"project": project_id,
"location": region,
"credentials": credentials
}
}
if "gemini-2.5" in model:
llm_config["automatic_function_calling"] = {"disable": True}
llm_config["tool_config"] = {"function_calling_config": {"mode": "any"}}
return GoogleGenAI(**llm_config)
Hello, I am having the same issue with 2.5-Flash . After lot of testing I am still not sure what is the problem but I managed to remedy the issue to certain degree:
The model could be overloaded so expect that you will have to send the request multiple times
It is needed to enhance the prompt so the model understand what output to produce. With 2.0-Flash the model used to return raw text if the schema failed. But now, with 2.5 it looks like if the schema fails one will get 500 error.
I just tried to run the Colab again multiple times with gemini-2.5-pro-preview-05-06 and it seems to work randomly half of the time. Unfortunately, we’re still getting some errors 500
The experimental model responds now, but it seems to mimic the tool calls, but actually does not call them. See the example content response start below; and there are no tool_calls in the response.