Skip to content

fix: use model_dump() instead of deprecated dict() in OpenAI output p… - #7850

Closed
intertermux-code wants to merge 1 commit into
getsentry:masterfrom
intertermux-code:fix/7827-pydantic-deprecated
Closed

intertermux-code wants to merge 1 commit into
getsentry:masterfrom
intertermux-code:fix/7827-pydantic-deprecated

Conversation

@intertermux-code

Copy link
Copy Markdown
Contributor

Description

_set_output_data in the OpenAI Agents integration (and _set_common_output_data in the OpenAI integration's Responses API path) serialized pydantic models with the v1 .dict() API. On pydantic v2 that emits PydanticDeprecatedSince20, 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. 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 calls
  • sentry_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_data with a function call plus a message carrying non-text content (the refusal path) under warnings.simplefilter("error", DeprecationWarning).

Issues

Reminders

  • Please add tests to validate your changes, and lint your code using uv run ruff.
  • Add GH Issue ID & Linear ID (if applicable)
  • PR title should use conventional commit style (feat:, fix:, meta:)

…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.
@intertermux-code
intertermux-code requested a review from a team as a code owner October 5, 2026 05:49
@alexander-alderman-webb

Copy link
Copy Markdown
Collaborator

Hi @intertermux-code.
You've opened a number of PRs in the repo. Please open one PR and we'll aim to review the PR.
I've closed your PRs now.

@intertermux-code

Copy link
Copy Markdown
Contributor Author

Done — the four fixes are consolidated in #7857. Sorry for the noise this morning.

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.

OpenAI Agents integration emits PydanticDeprecatedSince20 on tool calls - _set_output_data calls dict()

2 participants