mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
Use canonical indexed web access field (#31289)
## Summary - Rename the hosted web-search wire field to the canonical `indexed_web_access` spelling. - Preserve existing indexed-search behavior. ## Rollout Merge and release only after server support for `indexed_web_access` is fully deployed. ## Testing - `just fmt` - `just test -p codex-tools web_search_tool_spec_serializes_expected_wire_shape` - Blocking CI passed, including indexed web-search integration coverage.
This commit is contained in:
@@ -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),
|
||||
@@ -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)),
|
||||
|
||||
@@ -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()]),
|
||||
}),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
@@ -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))
|
||||
);
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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,
|
||||
@@ -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()]),
|
||||
}),
|
||||
@@ -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"],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user