Skip to content

fix(OpenAI): parse reasoning item content - #848

Merged
iBotPeaches merged 2 commits into
openai-php:mainfrom
pcbeingused333:fix/reasoning-item-content-c3047
Nov 15, 2026
Merged

iBotPeaches merged 2 commits into
openai-php:mainfrom
pcbeingused333:fix/reasoning-item-content-c3047

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What:

  • Bug Fix
  • New Feature

Description:

A Responses reasoning item can carry its chain of thought in content, a list of reasoning_text parts (the same shape conversation messages gained in #842). OutputReasoning::from() read only summary, encrypted_content, and status, so that text was dropped on the completed response and on streamed response.output_item events. Callers replaying the item, or reading reasoning from models that fill content instead of summary, received an empty item.

OutputReasoning now maps content through OutputReasoningText (text, type). A missing or null content stays null and is left out of toArray(), so existing payloads still round-trip. response.output_item events parse the item with the same class.

Tests cover a reasoning item that includes reasoning_text, an explicit null content, and an output_item.done event. The two content cases fail on main. The Pest suite passes (1456 passed, with the 35 deprecation notices already present on main). Pint and PHPStan are clean.

Related:

Follow-up to #842, which added reasoning_text parsing for conversation messages.

This change was prepared with an AI coding assistant.

OutputReasoning::from dropped the content array on a reasoning item, so reasoning_text never reached the completed response or a streamed output_item.
Premake content the same way as summary and spread it into a single toArray() payload, omitting the key when content is null.
@pcbeingused333

Copy link
Copy Markdown
Contributor Author

OutputReasoning::toArray() now builds content the same way as summary and returns a single payload. The null check is on that return: a null content is spread in as nothing, so the key stays off the array and existing items still round-trip. The reasoning-content tests pass (3), and Pint and PHPStan are clean on the file.

This comment was drafted with Claude Code.

@iBotPeaches
iBotPeaches merged commit c073ad9 into openai-php:main Nov 15, 2026
14 checks passed
@iBotPeaches

Copy link
Copy Markdown
Collaborator

thanks!

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.

2 participants