Skip to content

fix(openai,openai-agents): Serialize response output items with model_dump() - #8024

Closed
fbartho wants to merge 3 commits into
getsentry:masterfrom
fbartho:fb/openai-agents-model-dump
Closed

fbartho wants to merge 3 commits into
getsentry:masterfrom
fbartho:fb/openai-agents-model-dump

Conversation

@fbartho

@fbartho fbartho commented Oct 14, 2026 •

Copy link
Copy Markdown

Description

OpenAIIntegration (Responses API) and OpenAIAgentsIntegration serialize tool calls and non-text message content with the deprecated Pydantic v2 dict() method, so every response containing a function call or a refusal emits PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. when outputs are recorded.

Changes:

  • openai: replace the four dict() calls in _set_common_output_data with model_dump().
  • openai-agents: replace the two dict() calls in _set_output_data with model_dump().
  • Add test_responses_api_output_serialization_emits_no_pydantic_deprecation_warning (openai, both the data_collection and send_default_pii paths) and test_response_output_serialization_emits_no_pydantic_deprecation_warning (openai-agents), which assert no PydanticDeprecatedSince20 is emitted.

On Pydantic v1: openai's BaseModel defines model_dump() when Pydantic v1 is installed, delegating to dict(), in every version from 1.0.0, the integration's minimum. The Chat Completions path in the same function already calls choice.message.model_dump() on that basis. openai-agents requires pydantic>=2.10.

https://github.com/openai/openai-python/blob/becc1d20eed83c1b8d85e15dc131a372d9dc7813/src/openai/_models.py#L296-L372

The tox matrix pins Pydantic v2, so I also ran tests/integrations/openai/test_openai.py against openai 3.29.0 with pydantic 1.10.26: everything passes, and the new test skips.

Issues

Closes #7827

Recording tool calls and non-text message content called the deprecated Pydantic v2 `dict()` method, which emits `PydanticDeprecatedSince20`. `openai-agents` requires Pydantic v2 in every supported version, so `model_dump()` is always available.
Recording Responses API tool calls and non-text message content called the deprecated Pydantic v2 `dict()` method, which emits `PydanticDeprecatedSince20`. `openai`'s `BaseModel` defines `model_dump()` under Pydantic v1 in every supported version from `1.0.0`, so the call works with both Pydantic majors.
@fbartho
fbartho marked this pull request as ready for review October 14, 2026 00:14
@fbartho
fbartho requested a review from a team as a code owner October 14, 2026 00:14
@fbartho

fbartho commented Oct 14, 2026

Copy link
Copy Markdown
Author

Sorry, I didn't realize you had already fixed the main issue I was experiencing

@fbartho fbartho closed this Oct 14, 2026
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()

1 participant