From fc1ed2181d9d56c7350d4097424e474664c1ec68 Mon Sep 17 00:00:00 2001 From: Xsidz Date: Sun, 16 Aug 2026 22:21:42 +0530 Subject: [PATCH] fix(types): make ResponseFunctionWebSearch.action Optional Fixes #3179: the API can return a web_search_call item with action=null (observed on completed searches that returned cached results). The field was typed as non-optional, causing AttributeError at action.type access. Applied to both responses/ and beta/ variants. --- src/openai/types/beta/beta_response_function_web_search.py | 5 +++-- src/openai/types/responses/response_function_web_search.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/openai/types/beta/beta_response_function_web_search.py b/src/openai/types/beta/beta_response_function_web_search.py index af57015543..0cfdacb24a 100644 --- a/src/openai/types/beta/beta_response_function_web_search.py +++ b/src/openai/types/beta/beta_response_function_web_search.py @@ -86,10 +86,11 @@ class BetaResponseFunctionWebSearch(BaseModel): id: str """The unique ID of the web search tool call.""" - action: Action + action: Optional[Action] = None """ An object describing the specific action taken in this web search call. Includes - details on how the model used the web (search, open_page, find_in_page). + details on how the model used the web (search, open_page, find_in_page). May be + None when the search completed without a recorded action (e.g. cached results). """ status: Literal["in_progress", "searching", "completed", "failed"] diff --git a/src/openai/types/responses/response_function_web_search.py b/src/openai/types/responses/response_function_web_search.py index 44c6dd7a99..bbcdda03b9 100644 --- a/src/openai/types/responses/response_function_web_search.py +++ b/src/openai/types/responses/response_function_web_search.py @@ -78,10 +78,11 @@ class ResponseFunctionWebSearch(BaseModel): id: str """The unique ID of the web search tool call.""" - action: Action + action: Optional[Action] = None """ An object describing the specific action taken in this web search call. Includes - details on how the model used the web (search, open_page, find_in_page). + details on how the model used the web (search, open_page, find_in_page). May be + None when the search completed without a recorded action (e.g. cached results). """ status: Literal["in_progress", "searching", "completed", "failed"]