feat(tools): add search_content_types and image_settings to WebSearchTool - #4704
feat(tools): add search_content_types and image_settings to WebSearchTool#4704fuchengwarrenzhu wants to merge 2 commits into
Conversation
…Tool
The Responses API web_search tool accepts search_content_types
(["text", "image"]) and image_settings ({max_results, caption}) to
return image results alongside text. WebSearchTool had no way to set
them, so image search was unreachable through the SDK.
Both fields are optional and omitted from the tool payload when unset,
matching how external_web_access is passed through.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0118QL4rZytJhQHVCdYmkSRS
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f086a0b00
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Match the reviewed shape of openai#3474: when search_content_types includes "image", add the web_search_call.results include so image results are returned. Text-only configurations add no include. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0118QL4rZytJhQHVCdYmkSRS
|
Checked past PRs before opening this: #3474 (by @yuning-oai) proposed the same This PR carries the same converter shape as #3474, including the |
seratch
left a comment
There was a problem hiding this comment.
The platform need is valid: the current OpenAI documentation defines search_content_types, image_settings, and web_search_call.results for image search.
Two repository-readiness changes are still required:
- WebSearchToolImageSettings is part of the public WebSearchTool constructor annotation, so it must be exported from agents, included in the public export surface, and covered by an import regression test.
- Please remove the new docs/tools.md claim from this feature PR. Repository policy requires documentation for behavior unavailable in the latest published SDK release to land in a separately timed docs-only PR (I will handle this doc PR).
The provider conversion and automatic web_search_call.results include otherwise look appropriately scoped.
Summary
I encountered this issue when I'm trying to reconcile differences I'm observing with agentic workloads I'm running on top of the openai agent sdk vs. the ones ran on the Codex sdk.
In this PR, I'm adding two optional fields to
WebSearchToolso image search is reachable through the SDK:search_content_types: list[Literal["text", "image"]] | Noneimage_settings: WebSearchToolImageSettings | None— aTypedDictwithmax_results: intandcaption: boolBoth are omitted from the
web_searchtool payload when unset, the same wayexternal_web_accessis handled, so existing behaviour is unchanged.These map to the Responses API
web_searchtool fields documented in the web search guide (image results, currently withgpt-5.6).openai-pythondoes not yet type them onWebSearchToolParam, so the converter keeps building the payload as an untyped dict via_require_responses_tool_param, as it already does forexternal_web_access.Test plan
tests/models/test_openai_responses_converter.py: new test asserting both fields pass through; existing test extended to assert they are absent when unset.make format lint mypy pyrightclean;make tests: 9232 passed, 3 unrelated parallel-run flakes (realtime handshake timeout, unix-local pause/resume, cancelled-sibling cleanup) that pass serially on both this branch andmain.docs/tools.mdupdated (English only; translations left for the docs pipeline).