mirror of
https://github.com/openai/codex.git
synced 2026-12-01 00:20:48 +00:00
fix(config): accept bool or table for tools.web_search
Use a single backward-compatible tools.web_search field that accepts either a boolean or a config table with an enabled flag plus nested web search options. Update the core config resolver, app-server protocol, docs, generated schemas, and tests to match the union shape. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -16963,7 +16963,7 @@
|
||||
"web_search": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/v2/WebSearchToolConfig"
|
||||
"$ref": "#/definitions/v2/WebSearchToolConfigValue"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
@@ -17634,6 +17634,12 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"enabled": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"location": {
|
||||
"anyOf": [
|
||||
{
|
||||
@@ -17647,6 +17653,16 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"WebSearchToolConfigValue": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/v2/WebSearchToolConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
"WindowsSandboxSetupCompletedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
|
||||
@@ -14784,7 +14784,7 @@
|
||||
"web_search": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/WebSearchToolConfig"
|
||||
"$ref": "#/definitions/WebSearchToolConfigValue"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
@@ -15679,6 +15679,12 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"enabled": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"location": {
|
||||
"anyOf": [
|
||||
{
|
||||
@@ -15692,6 +15698,16 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"WebSearchToolConfigValue": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/WebSearchToolConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
"WindowsSandboxSetupCompletedNotification": {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
|
||||
@@ -741,7 +741,7 @@
|
||||
"web_search": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/WebSearchToolConfig"
|
||||
"$ref": "#/definitions/WebSearchToolConfigValue"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
@@ -828,6 +828,12 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"enabled": {
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"location": {
|
||||
"anyOf": [
|
||||
{
|
||||
@@ -840,6 +846,16 @@
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"WebSearchToolConfigValue": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/WebSearchToolConfig"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
import type { WebSearchContextSize } from "./WebSearchContextSize";
|
||||
import type { WebSearchLocation } from "./WebSearchLocation";
|
||||
|
||||
export type WebSearchToolConfig = { context_size: WebSearchContextSize | null, allowed_domains: Array<string> | null, location: WebSearchLocation | null, };
|
||||
export type WebSearchToolConfig = { enabled: boolean | null, context_size: WebSearchContextSize | null, allowed_domains: Array<string> | null, location: WebSearchLocation | null, };
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { WebSearchToolConfig } from "./WebSearchToolConfig";
|
||||
|
||||
export type WebSearchToolConfigValue = boolean | WebSearchToolConfig;
|
||||
@@ -231,4 +231,5 @@ export type { WebSearchItem } from "./WebSearchItem";
|
||||
export type { WebSearchLocation } from "./WebSearchLocation";
|
||||
export type { WebSearchMode } from "./WebSearchMode";
|
||||
export type { WebSearchToolConfig } from "./WebSearchToolConfig";
|
||||
export type { WebSearchToolConfigValue } from "./WebSearchToolConfigValue";
|
||||
export * as v2 from "./v2";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { WebSearchToolConfig } from "../WebSearchToolConfig";
|
||||
import type { WebSearchToolConfigValue } from "../WebSearchToolConfigValue";
|
||||
|
||||
export type ToolsV2 = { web_search: WebSearchToolConfig | null, view_image: boolean | null, };
|
||||
export type ToolsV2 = { web_search: WebSearchToolConfigValue | null, view_image: boolean | null, };
|
||||
|
||||
@@ -23,7 +23,7 @@ use codex_protocol::config_types::SandboxMode as CoreSandboxMode;
|
||||
use codex_protocol::config_types::ServiceTier;
|
||||
use codex_protocol::config_types::Verbosity;
|
||||
use codex_protocol::config_types::WebSearchMode;
|
||||
use codex_protocol::config_types::WebSearchToolConfig;
|
||||
use codex_protocol::config_types::WebSearchToolConfigValue;
|
||||
use codex_protocol::items::AgentMessageContent as CoreAgentMessageContent;
|
||||
use codex_protocol::items::TurnItem as CoreTurnItem;
|
||||
use codex_protocol::mcp::Resource as McpResource;
|
||||
@@ -498,7 +498,7 @@ pub struct SandboxWorkspaceWrite {
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ToolsV2 {
|
||||
pub web_search: Option<WebSearchToolConfig>,
|
||||
pub web_search: Option<WebSearchToolConfigValue>,
|
||||
pub view_image: Option<bool>,
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ Example with notification opt-out:
|
||||
- `mcpServerStatus/list` — enumerate configured MCP servers with their tools, resources, resource templates, and auth status; supports cursor+limit pagination.
|
||||
- `windowsSandbox/setupStart` — start Windows sandbox setup for the selected mode (`elevated` or `unelevated`); accepts an optional absolute `cwd` to target setup for a specific workspace, returns `{ started: true }` immediately, and later emits `windowsSandbox/setupCompleted`.
|
||||
- `feedback/upload` — submit a feedback report (classification + optional reason/logs, conversation_id, and optional `extraLogFiles` attachments array); returns the tracking thread id.
|
||||
- `config/read` — fetch the effective config on disk after resolving config layering.
|
||||
- `config/read` — fetch the effective config on disk after resolving config layering. In `tools`, `web_search` accepts either a boolean toggle or an object with `enabled` plus nested Responses web search options.
|
||||
- `externalAgentConfig/detect` — detect migratable external-agent artifacts with `includeHome` and optional `cwds`; each detected item includes `cwd` (`null` for home).
|
||||
- `externalAgentConfig/import` — apply selected external-agent migration items by passing explicit `migrationItems` with `cwd` (`null` for home).
|
||||
- `config/value/write` — write a single config key/value to the user's config.toml on disk.
|
||||
|
||||
@@ -26,6 +26,7 @@ use codex_protocol::config_types::TrustLevel;
|
||||
use codex_protocol::config_types::WebSearchContextSize;
|
||||
use codex_protocol::config_types::WebSearchLocation;
|
||||
use codex_protocol::config_types::WebSearchToolConfig;
|
||||
use codex_protocol::config_types::WebSearchToolConfigValue;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -131,11 +132,12 @@ view_image = false
|
||||
assert_eq!(
|
||||
tools,
|
||||
ToolsV2 {
|
||||
web_search: Some(WebSearchToolConfig {
|
||||
web_search: Some(WebSearchToolConfigValue::Config(WebSearchToolConfig {
|
||||
enabled: None,
|
||||
context_size: Some(WebSearchContextSize::Low),
|
||||
allowed_domains: Some(vec!["example.com".to_string()]),
|
||||
location: None,
|
||||
}),
|
||||
})),
|
||||
view_image: Some(false),
|
||||
}
|
||||
);
|
||||
@@ -203,7 +205,8 @@ location = { country = "US", city = "New York", timezone = "America/New_York" }
|
||||
|
||||
assert_eq!(
|
||||
config.tools.expect("tools present").web_search,
|
||||
Some(WebSearchToolConfig {
|
||||
Some(WebSearchToolConfigValue::Config(WebSearchToolConfig {
|
||||
enabled: None,
|
||||
context_size: Some(WebSearchContextSize::High),
|
||||
allowed_domains: Some(vec!["example.com".to_string()]),
|
||||
location: Some(WebSearchLocation {
|
||||
@@ -212,8 +215,61 @@ location = { country = "US", city = "New York", timezone = "America/New_York" }
|
||||
city: Some("New York".to_string()),
|
||||
timezone: Some("America/New_York".to_string()),
|
||||
}),
|
||||
})),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn config_read_includes_bool_web_search_toggle() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
write_config(
|
||||
&codex_home,
|
||||
r#"
|
||||
[tools]
|
||||
web_search = false
|
||||
"#,
|
||||
)?;
|
||||
let codex_home_path = codex_home.path().canonicalize()?;
|
||||
let user_file = AbsolutePathBuf::try_from(codex_home_path.join("config.toml"))?;
|
||||
|
||||
let mut mcp = McpProcess::new(codex_home.path()).await?;
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??;
|
||||
|
||||
let request_id = mcp
|
||||
.send_config_read_request(ConfigReadParams {
|
||||
include_layers: true,
|
||||
cwd: None,
|
||||
})
|
||||
.await?;
|
||||
let resp: JSONRPCResponse = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
let ConfigReadResponse {
|
||||
config,
|
||||
origins,
|
||||
layers,
|
||||
} = to_response(resp)?;
|
||||
|
||||
assert_eq!(
|
||||
config.tools,
|
||||
Some(ToolsV2 {
|
||||
web_search: Some(WebSearchToolConfigValue::Enabled(false)),
|
||||
view_image: None,
|
||||
}),
|
||||
);
|
||||
assert_eq!(
|
||||
origins.get("tools.web_search").expect("origin").name,
|
||||
ConfigLayerSource::User {
|
||||
file: user_file.clone(),
|
||||
}
|
||||
);
|
||||
|
||||
let layers = layers.expect("layers present");
|
||||
assert_layers_user_then_optional_system(&layers, user_file)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1504,10 +1504,11 @@
|
||||
"web_search": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/WebSearchToolConfig"
|
||||
"$ref": "#/definitions/WebSearchToolConfigValue"
|
||||
}
|
||||
],
|
||||
"default": null
|
||||
"default": null,
|
||||
"description": "Enable the native `web_search` tool with `true`/`false`, or provide a table with `enabled` and additional parameters."
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
@@ -1661,12 +1662,25 @@
|
||||
"context_size": {
|
||||
"$ref": "#/definitions/WebSearchContextSize"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"location": {
|
||||
"$ref": "#/definitions/WebSearchLocation"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"WebSearchToolConfigValue": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/WebSearchToolConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
"WindowsSandboxModeToml": {
|
||||
"enum": [
|
||||
"elevated",
|
||||
|
||||
@@ -14,6 +14,13 @@ use crate::config_loader::RequirementSource;
|
||||
use crate::features::Feature;
|
||||
use assert_matches::assert_matches;
|
||||
use codex_config::CONFIG_TOML_FILE;
|
||||
use codex_protocol::config_types::WebSearchContextSize;
|
||||
use codex_protocol::config_types::WebSearchFilters;
|
||||
use codex_protocol::config_types::WebSearchLocation;
|
||||
use codex_protocol::config_types::WebSearchToolConfig;
|
||||
use codex_protocol::config_types::WebSearchToolConfigValue;
|
||||
use codex_protocol::config_types::WebSearchUserLocation;
|
||||
use codex_protocol::config_types::WebSearchUserLocationType;
|
||||
use codex_protocol::permissions::FileSystemAccessMode;
|
||||
use codex_protocol::permissions::FileSystemPath;
|
||||
use codex_protocol::permissions::FileSystemSandboxEntry;
|
||||
@@ -1374,6 +1381,142 @@ fn web_search_mode_disabled_overrides_legacy_request() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_search_config_reads_legacy_tools_web_search_table() {
|
||||
let cfg = ConfigToml {
|
||||
tools: Some(ToolsToml {
|
||||
web_search: Some(WebSearchToolConfigValue::Config(WebSearchToolConfig {
|
||||
enabled: None,
|
||||
context_size: Some(WebSearchContextSize::High),
|
||||
allowed_domains: Some(vec!["example.com".to_string()]),
|
||||
location: Some(WebSearchLocation {
|
||||
country: Some("US".to_string()),
|
||||
region: None,
|
||||
city: Some("New York".to_string()),
|
||||
timezone: Some("America/New_York".to_string()),
|
||||
}),
|
||||
})),
|
||||
view_image: None,
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
let profile = ConfigProfile::default();
|
||||
|
||||
assert_eq!(
|
||||
resolve_web_search_config(&cfg, &profile),
|
||||
Some(WebSearchConfig {
|
||||
filters: Some(WebSearchFilters {
|
||||
allowed_domains: Some(vec!["example.com".to_string()]),
|
||||
}),
|
||||
user_location: Some(WebSearchUserLocation {
|
||||
r#type: WebSearchUserLocationType::Approximate,
|
||||
country: Some("US".to_string()),
|
||||
region: None,
|
||||
city: Some("New York".to_string()),
|
||||
timezone: Some("America/New_York".to_string()),
|
||||
}),
|
||||
search_context_size: Some(WebSearchContextSize::High),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_search_config_profile_overrides_base_values() {
|
||||
let cfg = ConfigToml {
|
||||
tools: Some(ToolsToml {
|
||||
web_search: Some(WebSearchToolConfigValue::Config(WebSearchToolConfig {
|
||||
enabled: Some(true),
|
||||
context_size: Some(WebSearchContextSize::Low),
|
||||
allowed_domains: Some(vec!["example.com".to_string()]),
|
||||
location: Some(WebSearchLocation {
|
||||
country: Some("US".to_string()),
|
||||
region: Some("CA".to_string()),
|
||||
city: None,
|
||||
timezone: Some("America/Los_Angeles".to_string()),
|
||||
}),
|
||||
})),
|
||||
view_image: None,
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
let profile = ConfigProfile {
|
||||
tools: Some(ToolsToml {
|
||||
web_search: Some(WebSearchToolConfigValue::Config(WebSearchToolConfig {
|
||||
enabled: None,
|
||||
context_size: Some(WebSearchContextSize::High),
|
||||
allowed_domains: None,
|
||||
location: Some(WebSearchLocation {
|
||||
country: None,
|
||||
region: Some("NY".to_string()),
|
||||
city: Some("New York".to_string()),
|
||||
timezone: None,
|
||||
}),
|
||||
})),
|
||||
view_image: None,
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
resolve_web_search_config(&cfg, &profile),
|
||||
Some(WebSearchConfig {
|
||||
filters: Some(WebSearchFilters {
|
||||
allowed_domains: Some(vec!["example.com".to_string()]),
|
||||
}),
|
||||
user_location: Some(WebSearchUserLocation {
|
||||
r#type: WebSearchUserLocationType::Approximate,
|
||||
country: Some("US".to_string()),
|
||||
region: Some("NY".to_string()),
|
||||
city: Some("New York".to_string()),
|
||||
timezone: Some("America/Los_Angeles".to_string()),
|
||||
}),
|
||||
search_context_size: Some(WebSearchContextSize::High),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tools_toml_web_search_projection_uses_enabled_value() {
|
||||
let tools = ToolsToml {
|
||||
web_search: Some(WebSearchToolConfigValue::Config(WebSearchToolConfig {
|
||||
enabled: Some(false),
|
||||
context_size: None,
|
||||
allowed_domains: None,
|
||||
location: None,
|
||||
})),
|
||||
view_image: Some(true),
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
codex_app_server_protocol::Tools::from(tools),
|
||||
codex_app_server_protocol::Tools {
|
||||
web_search: Some(false),
|
||||
view_image: Some(true),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tools_toml_web_search_projection_defaults_object_form_to_enabled() {
|
||||
let tools = ToolsToml {
|
||||
web_search: Some(WebSearchToolConfigValue::Config(WebSearchToolConfig {
|
||||
enabled: None,
|
||||
context_size: Some(WebSearchContextSize::Low),
|
||||
allowed_domains: None,
|
||||
location: None,
|
||||
})),
|
||||
view_image: None,
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
codex_app_server_protocol::Tools::from(tools),
|
||||
codex_app_server_protocol::Tools {
|
||||
web_search: Some(true),
|
||||
view_image: None,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_search_mode_for_turn_uses_preference_for_read_only() {
|
||||
let web_search_mode = Constrained::allow_any(WebSearchMode::Cached);
|
||||
|
||||
@@ -70,7 +70,7 @@ use codex_protocol::config_types::TrustLevel;
|
||||
use codex_protocol::config_types::Verbosity;
|
||||
use codex_protocol::config_types::WebSearchConfig;
|
||||
use codex_protocol::config_types::WebSearchMode;
|
||||
use codex_protocol::config_types::WebSearchToolConfig;
|
||||
use codex_protocol::config_types::WebSearchToolConfigValue;
|
||||
use codex_protocol::config_types::WindowsSandboxLevel;
|
||||
use codex_protocol::models::MacOsSeatbeltProfileExtensions;
|
||||
use codex_protocol::openai_models::ModelsResponse;
|
||||
@@ -1392,8 +1392,10 @@ pub struct RealtimeAudioToml {
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct ToolsToml {
|
||||
/// Enable the native `web_search` tool with `true`/`false`, or provide a
|
||||
/// table with `enabled` and additional parameters.
|
||||
#[serde(default)]
|
||||
pub web_search: Option<WebSearchToolConfig>,
|
||||
pub web_search: Option<WebSearchToolConfigValue>,
|
||||
|
||||
/// Enable the `view_image` tool that lets the agent attach local images.
|
||||
#[serde(default)]
|
||||
@@ -1457,7 +1459,7 @@ pub struct AgentRoleToml {
|
||||
impl From<ToolsToml> for Tools {
|
||||
fn from(tools_toml: ToolsToml) -> Self {
|
||||
Self {
|
||||
web_search: tools_toml.web_search.is_some().then_some(true),
|
||||
web_search: tools_toml.web_search.map(|web_search| web_search.enabled()),
|
||||
view_image: tools_toml.view_image,
|
||||
}
|
||||
}
|
||||
@@ -1756,11 +1758,13 @@ fn resolve_web_search_config(
|
||||
let base = config_toml
|
||||
.tools
|
||||
.as_ref()
|
||||
.and_then(|tools| tools.web_search.as_ref());
|
||||
.and_then(|tools| tools.web_search.as_ref())
|
||||
.and_then(WebSearchToolConfigValue::as_config);
|
||||
let profile = config_profile
|
||||
.tools
|
||||
.as_ref()
|
||||
.and_then(|tools| tools.web_search.as_ref());
|
||||
.and_then(|tools| tools.web_search.as_ref())
|
||||
.and_then(WebSearchToolConfigValue::as_config);
|
||||
|
||||
match (base, profile) {
|
||||
(None, None) => None,
|
||||
|
||||
@@ -145,14 +145,39 @@ impl WebSearchLocation {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct WebSearchToolConfig {
|
||||
pub enabled: Option<bool>,
|
||||
pub context_size: Option<WebSearchContextSize>,
|
||||
pub allowed_domains: Option<Vec<String>>,
|
||||
pub location: Option<WebSearchLocation>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(untagged)]
|
||||
pub enum WebSearchToolConfigValue {
|
||||
Enabled(bool),
|
||||
Config(WebSearchToolConfig),
|
||||
}
|
||||
|
||||
impl WebSearchToolConfigValue {
|
||||
pub fn enabled(&self) -> bool {
|
||||
match self {
|
||||
Self::Enabled(enabled) => *enabled,
|
||||
Self::Config(config) => config.enabled.unwrap_or(true),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_config(&self) -> Option<&WebSearchToolConfig> {
|
||||
match self {
|
||||
Self::Enabled(_) => None,
|
||||
Self::Config(config) => Some(config),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WebSearchToolConfig {
|
||||
pub fn merge(&self, other: &Self) -> Self {
|
||||
Self {
|
||||
enabled: other.enabled.or(self.enabled),
|
||||
context_size: other.context_size.or(self.context_size),
|
||||
allowed_domains: other
|
||||
.allowed_domains
|
||||
@@ -511,6 +536,7 @@ mod tests {
|
||||
#[test]
|
||||
fn web_search_tool_config_merge_prefers_overlay_values() {
|
||||
let base = WebSearchToolConfig {
|
||||
enabled: Some(true),
|
||||
context_size: Some(WebSearchContextSize::Low),
|
||||
allowed_domains: Some(vec!["openai.com".to_string()]),
|
||||
location: Some(WebSearchLocation {
|
||||
@@ -521,6 +547,7 @@ mod tests {
|
||||
}),
|
||||
};
|
||||
let overlay = WebSearchToolConfig {
|
||||
enabled: Some(false),
|
||||
context_size: Some(WebSearchContextSize::High),
|
||||
allowed_domains: None,
|
||||
location: Some(WebSearchLocation {
|
||||
@@ -532,6 +559,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let expected = WebSearchToolConfig {
|
||||
enabled: Some(false),
|
||||
context_size: Some(WebSearchContextSize::High),
|
||||
allowed_domains: Some(vec!["openai.com".to_string()]),
|
||||
location: Some(WebSearchLocation {
|
||||
@@ -544,4 +572,16 @@ mod tests {
|
||||
|
||||
assert_eq!(expected, base.merge(&overlay));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_search_tool_config_value_defaults_object_form_to_enabled() {
|
||||
let config_value = WebSearchToolConfigValue::Config(WebSearchToolConfig {
|
||||
enabled: None,
|
||||
context_size: Some(WebSearchContextSize::Low),
|
||||
allowed_domains: None,
|
||||
location: None,
|
||||
});
|
||||
|
||||
assert_eq!(config_value.enabled(), true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user