Skip to content

Nullable Fields Broken with Google GenAI Bump #3281

@MarlzRana

Description

@MarlzRana

Describe the bug
When defining a tool, that has optional fields, one runs into this issue:

Error in event_generator: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Unable to submit request because `create_payee` functionDeclaration `parameters.person.age` schema specified other fields alongside any_of. When using any_of, it must be the only field set. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling', 'status': 'INVALID_ARGUMENT'}}

To Reproduce
Steps to reproduce the behavior:

  1. Produce an MCP server with optional parameters, i.e:
from pydantic import BaseModel, Field
from fastmcp import FastMCP

class Person(BaseModel):
    name: str = Field(description="Person's name")
    age: int | None = Field(description="Person's age", ge=0)
    email: str | None = Field(description="Person's email address")
    occupation: str | None = Field(description="Person's occupation")

mcp = FastMCP("person-server")

@mcp.tool()
def create_person(person: Person) -> str:
    """Create a new person with optional parameters (name, age, email, occupation)."""
    pass
  
if __name__ == "__main__":
    mcp.run()
  1. Create an agent that uses this MCP tool, and one will run into the 400 I detailed prior, upon first message to the agent.

Additional context:
This is due a bump in the google-genai package, where it now handles dealing with the difference in ways one specifies nullable types between OpenAPI v3.1 and OpenAPI v3.0.

Expected behavior
One should be able to define tools with optional arguments.

Desktop (please complete the following information):

  • OS: macOS, Linux, Windows
  • Python version: 3.11.13
  • ADK version: 1.17.0

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: Gemini 2.5 Flash

Metadata

Metadata

Assignees

Labels

mcp[Component] Issues about MCP support

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions