Skip to content

pydantic-ai: capture web-search and grounding counts from RequestUsage.details #866

Description

pydantic-ai 2.52–2.54 started counting OpenAI native web searches (#8310) and Google grounding queries (#8891) in RequestUsage.details.

The usage extractor in py/src/braintrust/integrations/pydantic_ai/tracing.py (around lines 1388–1428) only reads reasoning and cached tokens from details.

Proposal

  • Record the new counts as metrics (or metadata if they aren't token counts), read defensively so older versions (0.1.9, 1.0.1, 1.10.0) are unaffected.
  • Optionally record the new workspace= run kwarg's kind in metadata (_AGENT_INPUT_ALLOWLIST already keeps the object itself out of spans).
  • Add cassette-backed coverage with a web-search tool run.

Parent: #858 (found while reviewing the 2026-10-05 weekly dependency update, #849).

🤖 Generated with Claude Code

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions