Skip to content

fix(pydantic-ai): capture conversation input on agent spans - #925

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/pydantic-conversation-vcr-f42f815a
Oct 13, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
abhi/pydantic-conversation-vcr-f42f815a

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

Agent spans omitted prior history when callers used pydantic-ai's conversation= argument. Capture its shaped messages as input.message_history and its ID as input.conversation_id, so existing trace normalizers display the full conversation. Normalize after forwarded kwargs so sync and event-stream APIs cannot overwrite the ID with a None default.

Adds cassette-backed regressions for all five instrumented agent run methods, gated to pydantic-ai >= 2.55.0. Consolidates overlapping agent/settings tests, removes one redundant direct-request test and its cassettes, and shares completion/streaming recordings across the conversation cases.

Validation:

  • Confirmed the conversation regressions fail before the fix and pass with recording disabled afterward.
  • All seven pydantic-ai nox sessions pass after rebasing onto main; cassette usage audit reports no unused recordings.
  • A real VCR-exported span preserves all three messages through both Lingua and the legacy UI normalizer.
  • Pre-commit, focused pylint, and lockfile consistency checks pass.

Fixes #923

Normalize Conversation messages and id into the existing message_history and
conversation_id input fields so trace normalizers retain prior turns.

Add version-gated VCR coverage for all five agent run methods and consolidate
overlapping pydantic-ai tests and recordings.

Fixes #923
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) marked this pull request as ready for review October 13, 2026 15:27
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T15:30:48.484837Z a877d92 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Scope unexpected-keyword-arg suppression to the conversation tests, which
require pydantic-ai >= 2.55.0. Python 3.10 lint uses an older compatible SDK
whose agent run signatures do not accept conversation yet.
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 44df5cb into main Oct 13, 2026
83 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the abhi/pydantic-conversation-vcr-f42f815a branch October 13, 2026 16:07
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.

pydantic-ai: capture conversation= input on agent spans

1 participant