Skip to content

pydantic-ai: capture conversation= input on agent spans #923

Description

pydantic-ai 2.55.0 added a conversation= keyword (a Conversation object) to all agent run entry points (pydantic/pydantic-ai#8337), as an alternative to message_history=.

_AGENT_INPUT_ALLOWLIST in py/src/braintrust/integrations/pydantic_ai/tracing.py doesn't include conversation. Users who pass conversation= get agent spans that are missing the prior history.

Proposed change

  • Capture conversation in the agent span input, ideally by extracting its messages and conversation id instead of serializing the raw object.
  • Add a cassette-backed test in test_pydantic_ai_integration.py, gated to versions >= 2.55.0.
  • Optional: 2.55.0 also added ModelResponse.failed_attempts (FallbackModel). Consider adding it to _RESPONSE_FIELDS.

Found while reviewing the dependency bumps in #911 (pydantic-ai 2.54.0 → 2.55.0).

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions