mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
fix
This commit is contained in:
@@ -1534,6 +1534,23 @@ fn web_search_mode_capability_override_false_disables_tool() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn web_search_mode_explicit_disabled_wins_when_capability_enabled() {
|
||||
let cfg = ConfigToml {
|
||||
web_search: Some(WebSearchMode::Disabled),
|
||||
..Default::default()
|
||||
};
|
||||
let profile = ConfigProfile::default();
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::WebSearchCached);
|
||||
let enabled_tools = BTreeSet::from(["web_search".to_string()]);
|
||||
|
||||
assert_eq!(
|
||||
resolve_web_search_mode(&cfg, &profile, &features, Some(&enabled_tools)),
|
||||
Some(WebSearchMode::Disabled)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_enabled_tool_capabilities_returns_none_when_omitted() {
|
||||
let cfg: ConfigToml = toml::from_str(
|
||||
|
||||
@@ -2073,9 +2073,7 @@ fn resolve_web_search_mode(
|
||||
|
||||
match enabled_tool_capabilities {
|
||||
Some(enabled_tool_capabilities) if enabled_tool_capabilities.contains("web_search") => {
|
||||
explicit_mode()
|
||||
.filter(|mode| *mode != WebSearchMode::Disabled)
|
||||
.or_else(feature_default_mode)
|
||||
explicit_mode().or_else(feature_default_mode)
|
||||
}
|
||||
Some(_) => Some(WebSearchMode::Disabled),
|
||||
None => explicit_mode().or_else(feature_default_mode),
|
||||
|
||||
@@ -141,7 +141,7 @@ impl BuiltinToolKey {
|
||||
Self::SpawnAgent => &["spawn_agent"],
|
||||
Self::SendInput => &["send_input"],
|
||||
Self::ResumeAgent => &["resume_agent"],
|
||||
Self::Wait => &["wait"],
|
||||
Self::Wait => &["wait_agent"],
|
||||
Self::CloseAgent => &["close_agent"],
|
||||
Self::SpawnAgentsOnCsv => &["spawn_agents_on_csv"],
|
||||
Self::ReportAgentJobResult => &["report_agent_job_result"],
|
||||
|
||||
@@ -3158,7 +3158,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
|
||||
create_spawn_agent_tool(config),
|
||||
/*supports_parallel_tool_calls*/ false,
|
||||
"spawn_agent",
|
||||
multi_agent_handler.clone(),
|
||||
Arc::new(SpawnAgentHandler),
|
||||
);
|
||||
push_builtin_tool_with_handler_if_enabled(
|
||||
&mut builder,
|
||||
@@ -3167,7 +3167,7 @@ pub(crate) fn build_specs_with_discoverable_tools(
|
||||
create_send_input_tool(),
|
||||
/*supports_parallel_tool_calls*/ false,
|
||||
"send_input",
|
||||
multi_agent_handler.clone(),
|
||||
Arc::new(SendInputHandler),
|
||||
);
|
||||
if !config.multi_agent_v2 {
|
||||
push_builtin_tool_with_handler_if_enabled(
|
||||
@@ -3177,18 +3177,18 @@ pub(crate) fn build_specs_with_discoverable_tools(
|
||||
create_resume_agent_tool(),
|
||||
/*supports_parallel_tool_calls*/ false,
|
||||
"resume_agent",
|
||||
multi_agent_handler.clone(),
|
||||
Arc::new(ResumeAgentHandler),
|
||||
);
|
||||
builder.register_handler("resume_agent", Arc::new(ResumeAgentHandler));
|
||||
}
|
||||
push_builtin_tool_with_handler_if_enabled(
|
||||
&mut builder,
|
||||
config,
|
||||
"wait",
|
||||
"wait_agent",
|
||||
create_wait_agent_tool(),
|
||||
/*supports_parallel_tool_calls*/ false,
|
||||
"wait",
|
||||
multi_agent_handler.clone(),
|
||||
"wait_agent",
|
||||
Arc::new(WaitAgentHandler),
|
||||
);
|
||||
push_builtin_tool_with_handler_if_enabled(
|
||||
&mut builder,
|
||||
@@ -3197,12 +3197,8 @@ pub(crate) fn build_specs_with_discoverable_tools(
|
||||
create_close_agent_tool(),
|
||||
/*supports_parallel_tool_calls*/ false,
|
||||
"close_agent",
|
||||
multi_agent_handler,
|
||||
Arc::new(CloseAgentHandler),
|
||||
);
|
||||
builder.register_handler("spawn_agent", Arc::new(SpawnAgentHandler));
|
||||
builder.register_handler("send_input", Arc::new(SendInputHandler));
|
||||
builder.register_handler("wait_agent", Arc::new(WaitAgentHandler));
|
||||
builder.register_handler("close_agent", Arc::new(CloseAgentHandler));
|
||||
}
|
||||
|
||||
if config.agent_jobs_tools {
|
||||
|
||||
@@ -13,6 +13,7 @@ use codex_protocol::openai_models::ModelInfo;
|
||||
use codex_protocol::openai_models::ModelsResponse;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::collections::BTreeSet;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::*;
|
||||
@@ -515,12 +516,49 @@ fn test_build_specs_collab_tools_enabled() {
|
||||
sandbox_policy: &SandboxPolicy::DangerFullAccess,
|
||||
windows_sandbox_level: WindowsSandboxLevel::Disabled,
|
||||
});
|
||||
let (tools, _) = build_specs(&tools_config, None, None, &[]).build();
|
||||
let (tools, registry) = build_specs(&tools_config, None, None, &[]).build();
|
||||
assert_contains_tool_names(
|
||||
&tools,
|
||||
&["spawn_agent", "send_input", "wait_agent", "close_agent"],
|
||||
);
|
||||
assert_lacks_tool_name(&tools, "spawn_agents_on_csv");
|
||||
assert!(registry.has_handler("spawn_agent", None));
|
||||
assert!(registry.has_handler("send_input", None));
|
||||
assert!(registry.has_handler("resume_agent", None));
|
||||
assert!(registry.has_handler("wait_agent", None));
|
||||
assert!(registry.has_handler("close_agent", None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_specs_multi_agent_handlers_omitted_when_capability_disabled() {
|
||||
let config = test_config();
|
||||
let model_info = ModelsManager::construct_model_info_offline_for_tests("gpt-5-codex", &config);
|
||||
let mut features = Features::with_defaults();
|
||||
features.enable(Feature::Collab);
|
||||
let available_models = Vec::new();
|
||||
let tools_config = ToolsConfig::new(&ToolsConfigParams {
|
||||
model_info: &model_info,
|
||||
available_models: &available_models,
|
||||
features: &features,
|
||||
web_search_mode: Some(WebSearchMode::Cached),
|
||||
session_source: SessionSource::Cli,
|
||||
sandbox_policy: &SandboxPolicy::DangerFullAccess,
|
||||
windows_sandbox_level: WindowsSandboxLevel::Disabled,
|
||||
})
|
||||
.with_enabled_tool_capabilities(Some(BTreeSet::new()));
|
||||
|
||||
let (tools, registry) = build_specs(&tools_config, None, None, &[]).build();
|
||||
|
||||
for tool_name in [
|
||||
"spawn_agent",
|
||||
"send_input",
|
||||
"resume_agent",
|
||||
"wait_agent",
|
||||
"close_agent",
|
||||
] {
|
||||
assert_lacks_tool_name(&tools, tool_name);
|
||||
assert!(!registry.has_handler(tool_name, None));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user