From 42b5f05cef69491bc578901fb324b3c9a278b253 Mon Sep 17 00:00:00 2001 From: jif Date: Fri, 14 Aug 2026 18:25:31 +0000 Subject: [PATCH] Preserve MCP namespace descriptions in the tool catalog cache (#38623) ## What changed Keep MCP namespace descriptions when publishing tool definitions to the process-scoped catalog cache. Cached definitions now expose the server instructions to the model before a lazily started MCP connection finishes initializing. ## Testing Update the cached MCP startup integration test to verify that cached namespace descriptions retain the originating server instructions. GitOrigin-RevId: d1b73381852fd43c6b54a7c22a599474c774dc20 --- codex-rs/codex-mcp/src/tool_catalog_cache.rs | 2 -- codex-rs/core/tests/suite/mcp_tool_cache.rs | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/codex-rs/codex-mcp/src/tool_catalog_cache.rs b/codex-rs/codex-mcp/src/tool_catalog_cache.rs index bb953dc5a8..e6e99f4acb 100644 --- a/codex-rs/codex-mcp/src/tool_catalog_cache.rs +++ b/codex-rs/codex-mcp/src/tool_catalog_cache.rs @@ -161,8 +161,6 @@ impl McpToolCatalogCacheContext { let mut tools = tools.to_vec(); for tool in &mut tools { - // Initialize instructions belong to one live connection and must not cross sessions. - tool.namespace_description = None; // Tool annotations affect approval and parallelism decisions, so only the live // connection may supply them. tool.tool.annotations = None; diff --git a/codex-rs/core/tests/suite/mcp_tool_cache.rs b/codex-rs/core/tests/suite/mcp_tool_cache.rs index d4c7c4259b..67795fac3b 100644 --- a/codex-rs/core/tests/suite/mcp_tool_cache.rs +++ b/codex-rs/core/tests/suite/mcp_tool_cache.rs @@ -534,7 +534,7 @@ async fn cached_mcp_startup_is_eager_for_root_and_lazy_for_subagents() -> anyhow ); assert_definition( &unused_response, - &format!("Tools in the {NAMESPACE} namespace."), + &format!("Use the tools from {cached_process}."), &format!("Echo from {cached_process}."), ); assert_eq!( @@ -631,7 +631,7 @@ async fn cached_mcp_startup_is_eager_for_root_and_lazy_for_subagents() -> anyhow .context("cached MCP definitions should reach inference before initialization")?; assert_definition( &cached_response, - &format!("Tools in the {NAMESPACE} namespace."), + &format!("Use the tools from {cached_process}."), &format!("Echo from {cached_process}."), ); let second_pid = wait_for_new_pid(fs.as_ref(), &pid_file, Some(&eager_pid)).await?;