langchain-ai/langchain-google

Attempting to use pydantic models as tool args causes `ParseError` in `ChatVertexAI`

Open

#1,076 opened on Aug 5, 2025

View on GitHub
 (4 comments) (3 reactions) (0 assignees)Python (461 forks)auto 404
help wantedvertexai

Repository metrics

Stars
 (392 stars)
PR merge metrics
 (PR metrics pending)

Description

Example Pydantic schema:

class IntOrFloat(BaseModel):
    """A type that can be either an int or a float."""

    number: int | float

and tool:

@tool
def add(a: IntOrFloat, b: IntOrFloat) -> IntOrFloat:
    """Adds a and b."""
    return IntOrFloat(number=a.number + b.number)

Attempting to use this tool in a tool-calling agent with ChatVertexAI causes the following error:

ParseError: Failed to parse properties field: Failed to parse properties field: Failed to parse anyOf field: Failed to parse type field: Invalid enum value integer for enum type google.cloud.aiplatform.v1beta1.Type at Schema.properties[a].properties[number].anyOf[0].type....

Contributor guide