Skip to content

Conversation

DouweM
Copy link
Collaborator

@DouweM DouweM commented Sep 19, 2025

Follow-up to #2954

Fixes this example reported on Slack:

from typing import TypedDict

import logfire
from pydantic_ai import Agent, WebSearchTool

logfire.configure()
logfire.instrument_pydantic_ai()


class Person(TypedDict):
    name: str
    age: int


agent = Agent(
    'anthropic:claude-sonnet-4-0',
    output_type=str | Person,
    builtin_tools=[WebSearchTool()],
    instructions="""
You are a helpful assistant that can find people online, and return their age, if you don't find it, explain me how I can find it.
""",
)

agent.run_sync("Search for Marcelo Trylesinski and return their age.")

@DouweM DouweM self-assigned this Sep 19, 2025
@DouweM DouweM enabled auto-merge (squash) September 19, 2025 13:08
@DouweM DouweM merged commit b36b598 into main Sep 19, 2025
30 checks passed
@DouweM DouweM deleted the otel-builtin-tools-fix branch September 19, 2025 13:13
Copy link

Docs Preview

commit: f166365
Preview URL: https://11a7fb11-pydantic-ai-previews.pydantic.workers.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants