Skip to content

UrlContextTool: '400 Tool use with function calling is unsupported' if output_type is specified #2761

@nvzoll

Description

@nvzoll

Initial Checks

Description

Trying to use UrlContextTool gives me an error

google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Tool use with function calling is unsupported', 'status': 'INVALID_ARGUMENT'}}

if I have output_type for the agent specified. When I remove output_type, it runs as expected.

Example Code

from pydantic_ai import Agent, UrlContextTool
from pydantic_ai.models.google import GoogleModel
from pydantic_ai.providers.google import GoogleProvider

GEMINI_API_KEY = '...'

agent = Agent(
    model=GoogleModel(
        "gemini-2.5-flash",
        provider=GoogleProvider(api_key=GEMINI_API_KEY),
    ),
    output_type=MyPydanticModel, # If we comment out this line, it works as expected
    system_prompt='system prompt here',
    builtin_tools=[UrlContextTool()],
)

res = await agent.run('user prompt here')

Python, Pydantic AI & LLM client version

Python 3.13.2
Pydantic AI 0.8.1
LLM gemini-2.5-flash, provider=GoogleProvider

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions