Skip to content

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

Closed

Description

@fbartho

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.71.0

Steps to Reproduce

  1. sentry_sdk.init(integrations=[OpenAIAgentsIntegration()], send_default_pii=True, traces_sample_rate=1.0) with openai-agents installed.
  2. Enable DeprecationWarnings (python -W error::DeprecationWarning, or any dependency that does so process-wide).
  3. Run an agent whose model response contains a function call.

Expected Result

No warning from sentry_sdk.

Actual Result

PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead.
  sentry_sdk/integrations/openai_agents/utils.py:229

The same warning comes from line 236 when a message contains non-text content such as a refusal.

for output in result.output:
if output.type == "function_call":
output_messages["tool"].append(output.dict())
elif output.type == "message":
for output_message in output.content:
try:
output_messages["response"].append(output_message.text)
except AttributeError:
# Unknown output message type, just return the json
output_messages["response"].append(output_message.dict())

Every supported openai-agents version requires Pydantic v2, so model_dump() is a drop-in replacement.

Activity

  1. linear-code commented on Oct 2, 2026

    @linear-code
  2. fbartho commented on Oct 2, 2026

    @fbartho
    Author

    I found this while updating some dependencies at work.

    I'll open a PR shortly since it's "just" a straight-forward migration.

    UPDATE: nevermind, reading CONTRIBUTING more closely, I need to wait until a maintainer responds. Let me know if you want a PR.

  3. fbartho commented on Oct 2, 2026

    @fbartho
    Author

    The same dict() pattern is in sentry_sdk/integrations/openai.py, in the Responses API output path:

    output_messages["tool"].append(output.dict())
    elif output.type == "message":
    for output_message in output.content:
    try:
    output_messages["response"].append(output_message.text) # type: ignore[union-attr]
    except AttributeError:
    # Unknown output message type, just return the json
    output_messages["response"].append(
    output_message.dict()
    )
    if len(output_messages["tool"]) > 0:
    set_data_normalized(
    span,
    SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS,
    output_messages["tool"],
    unpack=False,
    )
    if record_outputs and len(output_messages["response"]) > 0:
    set_data_normalized(
    span, SPANDATA.GEN_AI_RESPONSE_TEXT, output_messages["response"]
    )
    elif (
    should_send_default_pii()
    and integration.include_prompts
    and isinstance(response.output, list)
    ):
    for output in response.output:
    if output.type == "function_call":
    output_messages["tool"].append(output.dict())
    elif output.type == "message":
    for output_message in output.content:
    try:
    output_messages["response"].append(output_message.text) # type: ignore[union-attr]
    except AttributeError:
    # Unknown output message type, just return the json
    output_messages["response"].append(output_message.dict())

    Would you like those four calls fixed in the same pull request, or kept to openai_agents here and handled separately?

  4. alexander-alderman-webb commented on Oct 2, 2026

    @alexander-alderman-webb
    Collaborator

    Yes @fbartho, feel free to replace dict() with model_dump() in one PR.

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 2, 2026
  6. added 2 commits that reference this issue on Oct 5, 2026
    8012ab8
    d5b2293
  7. alexander-alderman-webb commented on Oct 5, 2026

    @alexander-alderman-webb
    Collaborator

    We can't blindly call model_dump() for openai-python because it allows old Pydantic versions in it's pyproject.toml

    https://github.com/openai/openai-python/blob/becc1d20eed83c1b8d85e15dc131a372d9dc7813/pyproject.toml#L13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions