chore(openai-agents): Use model_dump() instead of deprecated dict() - #7862
Merged
alexander-alderman-webb merged 4 commits intoOct 5, 2026
Merged
alexander-alderman-webb merged 4 commits into
alexander-alderman-webb merged 4 commits into
Conversation
…aths The pydantic v1 .dict() API emits PydanticDeprecatedSince20 on pydantic v2, which breaks anyone running with DeprecationWarnings as errors. Every supported openai/openai-agents version requires pydantic v2, so model_dump() is a drop-in replacement here. Fixes getsentry#7827.
alexander-alderman-webb
requested changes
Oct 5, 2026
Maintainer feedback: the new test duplicates coverage already provided by the existing suite, so it is not needed. The fix itself (model_dump() instead of dict()) is unchanged.
Contributor
|
This doesn't actually work because you can use I'm going to close this and write on the issue. |
Contributor
|
Or @intertermux-code feel free to apply the fix only for |
openai-python supports Pydantic v1 (where model_dump() doesn't exist), so revert the .dict() -> model_dump() change in the openai-python integration and keep it only in sentry_sdk/integrations/openai_agents/utils.py, where the openai-agents SDK guarantees Pydantic v2. Also fold the test import back to a single line; the multi-line form was only needed for the removed regression test's extra import.
Contributor
Author
|
Good catch — scoped it down to the openai-agents integration only and reverted the openai-python changes, since openai-python still supports Pydantic v1 where |
Restores the original multi-line form around output_message.dict(); no behavioral change. The model_dump() migration now applies only to the openai-agents integration, per review.
alexander-alderman-webb
approved these changes
Oct 5, 2026
model_dump() instead of deprecated dict()
alexander-alderman-webb
merged commit Oct 5, 2026
c5f80df
into
getsentry:master
309 of 311 checks passed
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.
Resubmitting as a single-change PR per your feedback on #7857.
Description
_set_output_datain the OpenAI Agents integration (and_set_common_output_datain the OpenAI integration's Responses API path) serialized pydantic models with the v1.dict()API. On pydantic v2 that emitsPydanticDeprecatedSince20, which breaks anyone running withDeprecationWarnings as errors.Every supported
openai/openai-agentsversion requires pydantic v2, so.model_dump()is a drop-in replacement. The OpenAI integration already calls.model_dump()unconditionally a few lines above (chat completions path), and the Anthropic/LiteLLM integrations use the same pattern.Changed:
sentry_sdk/integrations/openai_agents/utils.py: 2 callssentry_sdk/integrations/openai.py: 4 calls (both record-outputs branches of the Responses API path)Added
test_set_output_data_tool_calls_no_pydantic_deprecation, which runs_set_output_datawith a function call plus a message carrying non-text content (the refusal path) underwarnings.simplefilter("error", DeprecationWarning).Issues
PydanticDeprecatedSince20on tool calls -_set_output_datacallsdict()#7827Reminders
uv run ruff.feat:,fix:,meta:)