Skip to content

fix(core): avoid noisy pydantic serialization warnings for model_dump items#2443

Open
OiPunk wants to merge 2 commits intoopenai:mainfrom
OiPunk:codex/openai-agents-772-serialization-warning
Open

fix(core): avoid noisy pydantic serialization warnings for model_dump items#2443
OiPunk wants to merge 2 commits intoopenai:mainfrom
OiPunk:codex/openai-agents-772-serialization-warning

Conversation

@OiPunk
Copy link

@OiPunk OiPunk commented Feb 9, 2026

Summary

  • suppress pydantic serializer warnings when coercing model objects to API input dicts
  • add a safe fallback path for model_dump-compatible objects that do not accept the warnings argument
  • add regression coverage for container_file_citation-style payloads to ensure warning-free normalization

Problem

ensure_input_item_format / input item normalization can emit noisy PydanticSerializationUnexpectedValue warnings for mixed/legacy annotation payloads (for example container_file_citation variants). This muddies logs and affects common final_output/history handling workflows.

Fix

  • introduced _model_dump_without_warnings(...) in src/agents/run_internal/items.py
  • switched coercion paths to use this helper in both _coerce_to_dict and fingerprint_input_item
  • helper first tries model_dump(exclude_unset=True, warnings=False) and falls back to model_dump(exclude_unset=True) for compatibility

Tests

  • uv run ruff check src/agents/run_internal/items.py tests/test_agent_runner.py
  • uv run mypy . --exclude site
  • uv run pytest tests/test_agent_runner.py -k "ensure_api_input_item" -q
  • uv run coverage run -m pytest tests/test_agent_runner.py -k "ensure_api_input_item" -q && uv run coverage report -m src/agents/run_internal/items.py

Fixes #772

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54e0240704

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Pydantic Warnings and .final_output Serialization Issue with Code Interpreter File Citations

2 participants