ref(pydantic-ai): Move pydantic-ai object reads behind an extraction layer - #7194
Draft
ericapisani wants to merge 1 commit into
Draft
ref(pydantic-ai): Move pydantic-ai object reads behind an extraction layer#7194ericapisani wants to merge 1 commit into
ericapisani wants to merge 1 commit into
Conversation
…layer Introduce _extract.py as the module that concentrates reads of pydantic-ai object internals (private attributes, message part classes, version-dependent shapes) behind typed accessors returning plain data structures. Span modules and patches now consume those accessors, collapsing the duplicated message formatters and blob serializers into one implementation. Review-driven fixes folded in: response access in extract_response_model_name is now exception-safe (AgentRunResult.response can raise), token usage reporting goes through the shared record_token_usage helper, model-name resolution for the chat span name matches gen_ai.request.model resolution, and unknown model settings are skipped instead of raising KeyError.
Contributor
Codecov Results 📊✅ 111074 passed | ❌ 2 failed | ⏭️ 6759 skipped | Total: 117835 | Pass Rate: 94.26% | Execution Time: 400m 2s 📊 Comparison with Base Branch
➕ New Tests (1)View new tests
❌ Failed Tests
|
| File | Patch % | Lines |
|---|---|---|
| sentry_sdk/integrations/pydantic_ai/_extract.py | 92.68% | |
| sentry_sdk/integrations/pydantic_ai/spans/invoke_agent.py | 100.00% | |
| sentry_sdk/integrations/pydantic_ai/utils.py | 100.00% |
Coverage diff
@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 90.23% 90.26% +0.03%
==========================================
Files 193 194 +1
Lines 25361 25379 +18
Branches 9302 9282 -20
==========================================
+ Hits 22883 22907 +24
- Misses 2478 2472 -6
- Partials 1432 1425 -7Generated by Codecov Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Issues
Reminders
uv run ruff.feat:,fix:,ref:,meta:)Stack created with GitHub Stacks CLI • Give Feedback 💬