mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Avoid blocking turns on optional MCP startup (#35742)
## Why A pending optional MCP server can delay the first model request even when the turn does not need that server. ## What changed - Give optional MCP servers a shared one-second startup grace, then omit servers that are still pending from the captured tool catalog. - Continue waiting when the turn explicitly requires a server through a plugin, skill dependency, or `mcp://` mention, and preserve this behavior for input received between sampling steps. - Route direct resource requests to the live connection set when a pending server was omitted from the binding, while keeping all-server resource discovery non-blocking. ## Testing - Cover the shared grace period and resource behavior for pending optional servers. - Verify plugin, plugin-skill, and direct MCP mentions wait for startup. - Verify an Apps-enabled turn proceeds without tools from an unrelated pending optional server. GitOrigin-RevId: b5f895c5a5362fe73f7d33250367662d4a217e4d
This commit is contained in:
1 parent
8e271dc02b
commit
d9e1c9cd55
12 files changed
+519
-58
No files matched your search
@@ -23,6 +23,7 @@ pub use tool_catalog::tool_is_model_visible;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -144,6 +145,7 @@ impl McpServerView {
|
||||
pub(crate) struct McpConnectionSet {
|
||||
servers: HashMap<String, McpServerView>,
|
||||
required_servers: Vec<String>,
|
||||
optional_startup_deadline: OnceLock<tokio::time::Instant>,
|
||||
tool_catalog_revision: Arc<RwLock<u64>>,
|
||||
codex_apps_tools_override: RwLock<Option<Vec<ToolInfo>>>,
|
||||
codex_apps_refresh_lock: Mutex<()>,
|
||||
@@ -483,6 +485,7 @@ impl McpConnectionSet {
|
||||
let manager = Self {
|
||||
servers,
|
||||
required_servers,
|
||||
optional_startup_deadline: OnceLock::new(),
|
||||
tool_catalog_revision: Arc::new(RwLock::new(0)),
|
||||
codex_apps_tools_override: RwLock::new(None),
|
||||
codex_apps_refresh_lock: Mutex::new(()),
|
||||
@@ -540,6 +543,7 @@ impl McpConnectionSet {
|
||||
Self {
|
||||
servers: HashMap::new(),
|
||||
required_servers: Vec::new(),
|
||||
optional_startup_deadline: OnceLock::new(),
|
||||
tool_catalog_revision: Arc::new(RwLock::new(0)),
|
||||
codex_apps_tools_override: RwLock::new(None),
|
||||
codex_apps_refresh_lock: Mutex::new(()),
|
||||
|
||||
Reference in new issue
Block a user