diff --git a/codex-rs/core/src/client_common.rs b/codex-rs/core/src/client_common.rs index 913bb22321..27d52b490f 100644 --- a/codex-rs/core/src/client_common.rs +++ b/codex-rs/core/src/client_common.rs @@ -193,10 +193,8 @@ pub(crate) mod tools { Function(ResponsesApiTool), #[serde(rename = "local_shell")] LocalShell {}, - // TODO: Understand why we get an error on web_search although the API docs say it's supported. - // https://platform.openai.com/docs/guides/tools-web-search?api-mode=responses#:~:text=%7B%20type%3A%20%22web_search%22%20%7D%2C #[serde(rename = "web_search")] - WebSearch {}, + WebSearch(WebSearchTool), #[serde(rename = "custom")] Freeform(FreeformTool), } @@ -206,7 +204,7 @@ pub(crate) mod tools { match self { ToolSpec::Function(tool) => tool.name.as_str(), ToolSpec::LocalShell {} => "local_shell", - ToolSpec::WebSearch {} => "web_search", + ToolSpec::WebSearch(_) => "web_search", ToolSpec::Freeform(tool) => tool.name.as_str(), } } @@ -236,6 +234,11 @@ pub(crate) mod tools { pub(crate) strict: bool, pub(crate) parameters: JsonSchema, } + + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] + pub struct WebSearchTool { + pub(crate) external_web_access: bool, + } } pub struct ResponseStream { diff --git a/codex-rs/core/src/tools/spec.rs b/codex-rs/core/src/tools/spec.rs index 0ac91755c2..5108d79667 100644 --- a/codex-rs/core/src/tools/spec.rs +++ b/codex-rs/core/src/tools/spec.rs @@ -1,5 +1,6 @@ use crate::client_common::tools::ResponsesApiTool; use crate::client_common::tools::ToolSpec; +use crate::client_common::tools::WebSearchTool; use crate::features::Feature; use crate::features::Features; use crate::models_manager::model_family::ModelFamily; @@ -1094,7 +1095,9 @@ pub(crate) fn build_specs( } if config.web_search_request { - builder.push_spec(ToolSpec::WebSearch {}); + builder.push_spec(ToolSpec::WebSearch(WebSearchTool { + external_web_access: false, + })); } if config.include_view_image_tool {