Skip to content

fix(OpenAI): handle undocumented text web search results- #10 - #807

Merged
iBotPeaches merged 2 commits into
openai-php:mainfrom
e4se:fix-web-search-result
Sep 23, 2026
Merged

iBotPeaches merged 2 commits into
openai-php:mainfrom
e4se:fix-web-search-result

Conversation

@e4se

@e4se e4se commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

What:

  • Bug Fix
  • New Feature

Description:

Hotfixes a regression in Responses API web search result parsing.

web_search_call.results can contain undocumented text_result entries in addition to the documented image_result entries. Treating every result as an image attempted to read image_url from text results and caused an Undefined array key "image_url" exception.

  • Dispatch web_search_call.results entries by their type discriminator.
  • Parse image_result entries into typed OutputWebSearchToolCallImageResult objects.
  • Parse text_result entries into typed OutputWebSearchToolCallTextResult objects.
  • Preserve optional text result titles, URLs, and snippets.
  • Add regression coverage for both image and text result payloads.

The OpenAI documentation currently describes image result payloads but does not document the text_result variant: Image search results.

Tests:

  • Unit test suite: 1,140 passed (5,146 assertions).
  • Targeted web search tests: 10 passed (67 assertions).
  • PHPStan, code style, and PHP syntax checks passed.

@iBotPeaches iBotPeaches left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Slight breaking change here if people depended on the old class, but not much we can do if it split out to text vs image.

@iBotPeaches
iBotPeaches merged commit 3a28b3e into openai-php:main Sep 23, 2026
14 checks passed
@iBotPeaches iBotPeaches added this to the v0.22.0 milestone Sep 23, 2026
@e4se

e4se commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Yes, my bad — I didn’t catch that this broke the default web search without image(

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