From ca2b47997e5f67c6f40be7e51c244f5bc68b04d2 Mon Sep 17 00:00:00 2001 From: jif Date: Mon, 3 Aug 2026 15:41:38 +0000 Subject: [PATCH] Avoid building code-mode definitions during registration (#36764) ## What changed Derive code-mode tool names directly from registered tool names when checking eligibility and collisions. Skip unsupported and empty tool specs explicitly, without serializing schemas or augmenting descriptions that are not used during executor registration. GitOrigin-RevId: b439327aafd85ce3745d900301b7e48b56dbd6b4 --- codex-rs/core/src/tools/spec_plan.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/codex-rs/core/src/tools/spec_plan.rs b/codex-rs/core/src/tools/spec_plan.rs index 157644d37d..c4e10393d7 100644 --- a/codex-rs/core/src/tools/spec_plan.rs +++ b/codex-rs/core/src/tools/spec_plan.rs @@ -530,12 +530,21 @@ fn register_code_mode_executors( } let spec = tool.runtime.spec(); - let Some(code_mode_tool) = codex_tools::tool_spec_to_code_mode_tool_definition(&spec) - else { - continue; + // Derive the name without serializing and augmenting every tool schema. + let code_mode_name = match &spec { + ToolSpec::Function(_) | ToolSpec::Freeform(_) => { + codex_tools::code_mode_name_for_tool_name(&tool_name) + } + ToolSpec::Namespace(namespace) if !namespace.tools.is_empty() => { + codex_tools::code_mode_name_for_tool_name(&tool_name) + } + ToolSpec::Namespace(_) | ToolSpec::ToolSearch { .. } | ToolSpec::WebSearch { .. } => { + continue; + } }; - - let code_mode_name = code_mode_tool.name; + if !codex_code_mode::is_code_mode_nested_tool(&code_mode_name) { + continue; + } match code_mode_tool_names.entry(codex_code_mode::normalize_code_mode_identifier( &code_mode_name, )) {