mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +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:
1 parent
58b66d39e4
commit
07d631875e
6 files changed
+12
-11
No files matched your search
@@ -18,7 +18,7 @@ pub fn create_image_generation_tool(output_format: &str) -> ToolSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_web_search_tool(options: WebSearchToolOptions<'_>) -> Option<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::Cached) => (false, None),
|
||||||
Some(WebSearchMode::Indexed) => (true, Some(true)),
|
Some(WebSearchMode::Indexed) => (true, Some(true)),
|
||||||
Some(WebSearchMode::Live) => (true, None),
|
Some(WebSearchMode::Live) => (true, None),
|
||||||
@@ -37,7 +37,7 @@ pub fn create_web_search_tool(options: WebSearchToolOptions<'_>) -> Option<ToolS
|
|||||||
|
|
||||||
Some(ToolSpec::WebSearch {
|
Some(ToolSpec::WebSearch {
|
||||||
external_web_access: Some(external_web_access),
|
external_web_access: Some(external_web_access),
|
||||||
index_gated_web_access,
|
indexed_web_access,
|
||||||
filters: options
|
filters: options
|
||||||
.web_search_config
|
.web_search_config
|
||||||
.and_then(|config| config.filters.clone().map(Into::into)),
|
.and_then(|config| config.filters.clone().map(Into::into)),
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ fn web_search_tool_preserves_configured_options() {
|
|||||||
}),
|
}),
|
||||||
Some(ToolSpec::WebSearch {
|
Some(ToolSpec::WebSearch {
|
||||||
external_web_access: Some(true),
|
external_web_access: Some(true),
|
||||||
index_gated_web_access: None,
|
indexed_web_access: None,
|
||||||
filters: Some(ResponsesApiWebSearchFilters {
|
filters: Some(ResponsesApiWebSearchFilters {
|
||||||
allowed_domains: Some(vec!["example.com".to_string()]),
|
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"),
|
live_web_search.visible_spec("web_search"),
|
||||||
&ToolSpec::WebSearch {
|
&ToolSpec::WebSearch {
|
||||||
external_web_access: Some(true),
|
external_web_access: Some(true),
|
||||||
index_gated_web_access: None,
|
indexed_web_access: None,
|
||||||
filters: None,
|
filters: None,
|
||||||
user_location: None,
|
user_location: None,
|
||||||
search_context_size: 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)]
|
#[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!();
|
skip_if_no_network!();
|
||||||
|
|
||||||
let server = start_mock_server().await;
|
let server = start_mock_server().await;
|
||||||
@@ -308,7 +308,7 @@ async fn indexed_web_search_mode_sets_index_gate() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
(
|
(
|
||||||
tool.get("external_web_access").and_then(Value::as_bool),
|
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))
|
(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
|
// TODO: Understand why we get an error on web_search although the API docs
|
||||||
// say it's supported.
|
// 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
|
// 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
|
// `external_web_access` distinguishes cached from live-capable search, while
|
||||||
// cached or live content.
|
// `indexed_web_access` restricts live fetches to indexed URLs.
|
||||||
// https://platform.openai.com/docs/guides/tools-web-search#live-internet-access
|
// https://platform.openai.com/docs/guides/tools-web-search#live-internet-access
|
||||||
#[serde(rename = "web_search")]
|
#[serde(rename = "web_search")]
|
||||||
WebSearch {
|
WebSearch {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
external_web_access: Option<bool>,
|
external_web_access: Option<bool>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[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")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
filters: Option<ResponsesApiWebSearchFilters>,
|
filters: Option<ResponsesApiWebSearchFilters>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ fn tool_spec_name_covers_all_variants() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
ToolSpec::WebSearch {
|
ToolSpec::WebSearch {
|
||||||
external_web_access: Some(true),
|
external_web_access: Some(true),
|
||||||
index_gated_web_access: None,
|
indexed_web_access: None,
|
||||||
filters: None,
|
filters: None,
|
||||||
user_location: None,
|
user_location: None,
|
||||||
search_context_size: None,
|
search_context_size: None,
|
||||||
@@ -200,7 +200,7 @@ fn web_search_tool_spec_serializes_expected_wire_shape() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
serde_json::to_value(ToolSpec::WebSearch {
|
serde_json::to_value(ToolSpec::WebSearch {
|
||||||
external_web_access: Some(true),
|
external_web_access: Some(true),
|
||||||
index_gated_web_access: None,
|
indexed_web_access: Some(true),
|
||||||
filters: Some(ResponsesApiWebSearchFilters {
|
filters: Some(ResponsesApiWebSearchFilters {
|
||||||
allowed_domains: Some(vec!["example.com".to_string()]),
|
allowed_domains: Some(vec!["example.com".to_string()]),
|
||||||
}),
|
}),
|
||||||
@@ -218,6 +218,7 @@ fn web_search_tool_spec_serializes_expected_wire_shape() {
|
|||||||
json!({
|
json!({
|
||||||
"type": "web_search",
|
"type": "web_search",
|
||||||
"external_web_access": true,
|
"external_web_access": true,
|
||||||
|
"indexed_web_access": true,
|
||||||
"filters": {
|
"filters": {
|
||||||
"allowed_domains": ["example.com"],
|
"allowed_domains": ["example.com"],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user