Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions codex-rs/core/src/tools/hosted_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn create_image_generation_tool(output_format: &str) -> ToolSpec {
}

pub fn create_web_search_tool(options: WebSearchToolOptions<'_>) -> Option<ToolSpec> {
let (external_web_access, index_gated_web_access) = match options.web_search_mode {
let (external_web_access, indexed_web_access) = match options.web_search_mode {
Some(WebSearchMode::Cached) => (false, None),
Some(WebSearchMode::Indexed) => (true, Some(true)),
Some(WebSearchMode::Live) => (true, None),
Expand All @@ -37,7 +37,7 @@ pub fn create_web_search_tool(options: WebSearchToolOptions<'_>) -> Option<ToolS

Some(ToolSpec::WebSearch {
external_web_access: Some(external_web_access),
index_gated_web_access,
indexed_web_access,
filters: options
.web_search_config
.and_then(|config| config.filters.clone().map(Into::into)),
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/core/src/tools/hosted_spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn web_search_tool_preserves_configured_options() {
}),
Some(ToolSpec::WebSearch {
external_web_access: Some(true),
index_gated_web_access: None,
indexed_web_access: None,
filters: Some(ResponsesApiWebSearchFilters {
allowed_domains: Some(vec!["example.com".to_string()]),
}),
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/core/src/tools/spec_plan_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ async fn hosted_tools_follow_provider_auth_model_and_config_gates() {
live_web_search.visible_spec("web_search"),
&ToolSpec::WebSearch {
external_web_access: Some(true),
index_gated_web_access: None,
indexed_web_access: None,
filters: None,
user_location: None,
search_context_size: None,
Expand Down
4 changes: 2 additions & 2 deletions codex-rs/core/tests/suite/web_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ location = { country = "US", city = "New York", timezone = "America/New_York" }
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn indexed_web_search_mode_sets_index_gate() {
async fn indexed_web_search_mode_sets_indexed_access() {
skip_if_no_network!();

let server = start_mock_server().await;
Expand Down Expand Up @@ -308,7 +308,7 @@ async fn indexed_web_search_mode_sets_index_gate() {
assert_eq!(
(
tool.get("external_web_access").and_then(Value::as_bool),
tool.get("index_gated_web_access").and_then(Value::as_bool),
tool.get("indexed_web_access").and_then(Value::as_bool),
),
(Some(true), Some(true))
);
Expand Down
6 changes: 3 additions & 3 deletions codex-rs/tools/src/tool_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ pub enum ToolSpec {
// 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
// The `external_web_access` field determines whether the web search is over
// cached or live content.
// `external_web_access` distinguishes cached from live-capable search, while
// `indexed_web_access` restricts live fetches to indexed URLs.
// https://platform.openai.com/docs/guides/tools-web-search#live-internet-access
#[serde(rename = "web_search")]
WebSearch {
#[serde(skip_serializing_if = "Option::is_none")]
external_web_access: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
index_gated_web_access: Option<bool>,
indexed_web_access: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
filters: Option<ResponsesApiWebSearchFilters>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
5 changes: 3 additions & 2 deletions codex-rs/tools/src/tool_spec_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn tool_spec_name_covers_all_variants() {
assert_eq!(
ToolSpec::WebSearch {
external_web_access: Some(true),
index_gated_web_access: None,
indexed_web_access: None,
filters: None,
user_location: None,
search_context_size: None,
Expand Down Expand Up @@ -200,7 +200,7 @@ fn web_search_tool_spec_serializes_expected_wire_shape() {
assert_eq!(
serde_json::to_value(ToolSpec::WebSearch {
external_web_access: Some(true),
index_gated_web_access: None,
indexed_web_access: Some(true),
filters: Some(ResponsesApiWebSearchFilters {
allowed_domains: Some(vec!["example.com".to_string()]),
}),
Expand All @@ -218,6 +218,7 @@ fn web_search_tool_spec_serializes_expected_wire_shape() {
json!({
"type": "web_search",
"external_web_access": true,
"indexed_web_access": true,
"filters": {
"allowed_domains": ["example.com"],
},
Expand Down
Loading