From 1a633e0b161e65e94c5b85f2485009a6958d5d5c Mon Sep 17 00:00:00 2001 From: Gautam Kishore Date: Fri, 10 Jul 2026 16:28:32 +0530 Subject: [PATCH] fix(types): make ResponseFunctionWebSearch.action optional The API returns action=None for some completed web search calls, but the type declares action as required, causing attribute access (e.g. item.action.type) to break under strict typing. Make action Optional[Action] = None in both the stable and beta response types. Fixes #3179 --- src/openai/types/beta/beta_response_function_web_search.py | 5 ++++- src/openai/types/responses/response_function_web_search.py | 5 ++++- 2 files changed, 8 insertions(+), 2 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 0d1a20e401..b59f9f0fa2 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,13 @@ 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). + + May be `None` when the web search call did not produce a specific action (e.g. some + completed calls return no `action` in the API response). """ 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 3584992b7d..9d6c55ab5a 100644 --- a/src/openai/types/responses/response_function_web_search.py +++ b/src/openai/types/responses/response_function_web_search.py @@ -78,10 +78,13 @@ 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). + + May be `None` when the web search call did not produce a specific action (e.g. some + completed calls return no `action` in the API response). """ status: Literal["in_progress", "searching", "completed", "failed"]