Skip to content

fix(pydantic-ai): Stop emitting duplicate spans - #7056

Open
alexander-alderman-webb wants to merge 5 commits into
masterfrom
webb/pydantic-avoid-double-spans
Open

fix(pydantic-ai): Stop emitting duplicate spans#7056
alexander-alderman-webb wants to merge 5 commits into
masterfrom
webb/pydantic-avoid-double-spans

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

Do not create a duplicate AI Client span in the cases that ModelRequestNode.run() or ModelRequestNode.stream() hit an early return path in which no model request is made.

Replace len(chat_spans) >= 1 with len(chat_spans) == 1 in tests.

Issues

Reminders

Comment thread sentry_sdk/integrations/pydantic_ai/patches/graph_nodes.py
@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review August 6, 2026 08:27
@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner August 6, 2026 08:27

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1e96035. Configure here.

Comment thread tests/integrations/pydantic_ai/test_pydantic_ai.py Outdated
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

99162 passed | ⏭️ 6479 skipped | Total: 105641 | Pass Rate: 93.87% | Execution Time: 363m 15s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests 📈 +1
Failed Tests 📉 -1
Skipped Tests

➖ Removed Tests (1)

View removed tests
  • test_continuous_profiler_auto_start_and_stop_sampled[experiment-gevent]
    • File: tests.profiler.test_continuous_profiler

All tests are passing successfully.

❌ Patch coverage is 66.67%. Project has 2509 uncovered lines.
✅ Project coverage is 89.95%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/pydantic_ai/patches/graph_nodes.py 66.67% ⚠️ 3 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.95%    89.95%        —%
==========================================
  Files          193       193         —
  Lines        24955     24964        +9
  Branches      9004      9008        +4
==========================================
+ Hits         22448     22455        +7
- Misses        2507      2509        +2
- Partials      1437      1437         —

Generated by Codecov Action

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