mirror of
https://github.com/openai/codex.git
synced 2026-11-22 15:15:18 +00:00
Add tool registry collision policy configuration (#36954)
## What changed - Add `features.tool_registry.error_on_tool_collisions`, defaulting to `false`, to the TOML model, generated schema, and resolved runtime configuration. - Treat `tool_registry` as structured configuration rather than a feature toggle, including in strict config validation and profile configuration. - Preserve the resolved collision policy in session config lockfiles when it is enabled or explicitly configured. ## Testing - Cover deserialization, strict validation, default and enabled resolution, feature materialization, and config lockfile serialization. GitOrigin-RevId: 2c27109dcf2a3d1e51064cc60088703e36a0f85a
This commit is contained in:
1 parent
b87981a510
commit
9952933c1d
11 files changed
+151
-6
No files matched your search
@@ -568,6 +568,36 @@ disable_in_process_fallback = true
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn load_config_resolves_tool_registry_config() -> std::io::Result<()> {
|
||||
let codex_home = tempdir()?;
|
||||
|
||||
for (config_toml, error_on_tool_collisions) in [
|
||||
("", false),
|
||||
(
|
||||
"[features.tool_registry]\nerror_on_tool_collisions = true\n",
|
||||
true,
|
||||
),
|
||||
] {
|
||||
let config_toml: ConfigToml =
|
||||
toml::from_str(config_toml).expect("TOML deserialization should succeed");
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
config_toml,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.abs(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert_eq!(
|
||||
config.tool_registry.error_on_tool_collisions,
|
||||
error_on_tool_collisions
|
||||
);
|
||||
assert!(!config.features.enabled(Feature::CodeMode));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn load_config_resolves_token_budget_config() -> std::io::Result<()> {
|
||||
for (config_toml, expected) in [
|
||||
|
||||
@@ -1030,6 +1030,9 @@ pub struct Config {
|
||||
/// Whether to register the update_plan tool.
|
||||
pub update_plan_enabled: bool,
|
||||
|
||||
/// Policy for collecting and validating tool runtimes.
|
||||
pub tool_registry: ToolRegistryConfig,
|
||||
|
||||
/// Configuration for the experimental code-mode tool surface.
|
||||
pub code_mode: CodeModeConfig,
|
||||
|
||||
@@ -1092,6 +1095,12 @@ pub struct Config {
|
||||
pub otel: codex_config::types::OtelConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)]
|
||||
pub struct ToolRegistryConfig {
|
||||
/// Fail the turn when multiple tools share the same effective name.
|
||||
pub error_on_tool_collisions: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)]
|
||||
pub struct CodeModeConfig {
|
||||
pub excluded_tool_namespaces: Vec<String>,
|
||||
@@ -3640,6 +3649,14 @@ impl Config {
|
||||
let experimental_request_user_input_enabled =
|
||||
resolve_experimental_request_user_input_enabled(&cfg);
|
||||
let update_plan_enabled = resolve_update_plan_enabled(&cfg);
|
||||
let tool_registry = ToolRegistryConfig {
|
||||
error_on_tool_collisions: cfg
|
||||
.features
|
||||
.as_ref()
|
||||
.and_then(|features| features.tool_registry.as_ref())
|
||||
.and_then(|config| config.error_on_tool_collisions)
|
||||
.unwrap_or_default(),
|
||||
};
|
||||
let code_mode = resolve_code_mode_config(&cfg);
|
||||
let multi_agent_v2 = resolve_multi_agent_v2_config(&cfg);
|
||||
let token_budget = resolve_token_budget_config(&cfg, &features)?;
|
||||
@@ -4172,6 +4189,7 @@ impl Config {
|
||||
web_search_config,
|
||||
experimental_request_user_input_enabled,
|
||||
update_plan_enabled,
|
||||
tool_registry,
|
||||
code_mode,
|
||||
use_experimental_unified_exec_tool,
|
||||
background_terminal_max_timeout,
|
||||
|
||||
Reference in new issue
Block a user