Skip to content

fix(conversations): skip persisting empty reasoning items (#3268)#3323

Draft
GopalGB wants to merge 1 commit intoopenai:mainfrom
GopalGB:fix/conversations-session-empty-reasoning-item
Draft

fix(conversations): skip persisting empty reasoning items (#3268)#3323
GopalGB wants to merge 1 commit intoopenai:mainfrom
GopalGB:fix/conversations-session-empty-reasoning-item

Conversation

@GopalGB
Copy link
Copy Markdown
Contributor

@GopalGB GopalGB commented May 9, 2026

Summary

Closes #3268.

`run_item_to_input_item` now returns `None` for reasoning items whose `summary` list is empty, so they are omitted from model input (matching the existing `tool_approval_item` pattern).

Why

Encrypted-reasoning turns frequently produce items with no visible summary (`{"type": "reasoning", "summary": []}`). The Conversations API rejects these with a 400, breaking session resume on any agent that uses encrypted reasoning. The fix skips them at the conversion boundary rather than letting the empty payload reach the API.

Change

  • `src/agents/run_internal/items.py`: 15-line addition in `run_item_to_input_item` — returns `None` when `run_item.type == "reasoning_item"` and `input_item["summary"]` is empty/missing. Docstring updated.
  • `tests/test_run_internal_items.py`: new regression test `test_run_item_to_input_item_skips_reasoning_item_with_empty_summary`.

Test plan

  • `pytest tests/test_run_internal_items.py` — 22/22 pass locally
  • `ruff check` — clean
  • No behavior change for reasoning items with non-empty summary
  • Existing `tool_approval_item` skip-pattern preserved

Reasoning items with an empty summary list cause a 400 from the Conversations
API. Encrypted-reasoning turns frequently produce these (model emits no visible
summary). run_item_to_input_item now returns None for such items so they are
omitted from the model input, matching the existing tool_approval_item pattern.
@github-actions github-actions Bot added bug Something isn't working feature:core labels May 9, 2026
@seratch seratch marked this pull request as draft May 9, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAIConversationsSession persists empty reasoning item {"type":"reasoning","summary":[]} and Conversations API rejects it as invalid

1 participant