mirror of
https://github.com/openai/codex.git
synced 2026-11-19 15:04:25 +00:00
Make the optional MCP startup grace configurable (#41199)
## What changed - Add `mcp_optional_startup_grace_ms` with a default of 1,000 ms to control how long tool catalog capture waits for optional MCP servers. - Treat a value of `0` as disabling the shared grace, so optional servers use their configured `startup_timeout_sec` instead. - Apply updated grace values during runtime and MCP configuration refreshes, and reset cached startup deadlines when the configured duration changes. ## Testing - Cover custom, disabled, refreshed, and shared startup grace behavior in MCP connection and core integration tests. GitOrigin-RevId: 936196215ed6e0a29c9ec72cfee17663978df8ef
This commit is contained in:
1 parent
035295b46e
commit
124e560b93
14 files changed
+495
-17
No files matched your search
@@ -56,11 +56,16 @@ struct ToolCatalogCacheEntry {
|
||||
#[derive(Default)]
|
||||
struct ToolCatalogCacheState {
|
||||
snapshot: Option<ToolCatalogSnapshot>,
|
||||
optional_startup_deadline: Option<Instant>,
|
||||
optional_startup_deadline: Option<OptionalStartupDeadline>,
|
||||
last_accepted_generation: u64,
|
||||
disabled_by_server: bool,
|
||||
}
|
||||
|
||||
struct OptionalStartupDeadline {
|
||||
grace: Duration,
|
||||
deadline: Instant,
|
||||
}
|
||||
|
||||
struct ToolCatalogSnapshot {
|
||||
tools: Vec<ToolInfo>,
|
||||
published_at: Instant,
|
||||
@@ -114,7 +119,11 @@ impl McpToolCatalogCacheContext {
|
||||
self.current_tools().is_some_and(|tools| !tools.is_empty())
|
||||
}
|
||||
|
||||
pub(crate) fn optional_startup_deadline(&self, default_deadline: Instant) -> Instant {
|
||||
pub(crate) fn optional_startup_deadline(
|
||||
&self,
|
||||
default_deadline: Instant,
|
||||
startup_grace: Duration,
|
||||
) -> Instant {
|
||||
let mut state = lock_unpoisoned(&self.entry.state);
|
||||
if state.disabled_by_server
|
||||
|| state
|
||||
@@ -124,9 +133,20 @@ impl McpToolCatalogCacheContext {
|
||||
{
|
||||
return default_deadline;
|
||||
}
|
||||
*state
|
||||
.optional_startup_deadline
|
||||
.get_or_insert(default_deadline)
|
||||
let cached_deadline =
|
||||
state
|
||||
.optional_startup_deadline
|
||||
.get_or_insert(OptionalStartupDeadline {
|
||||
grace: startup_grace,
|
||||
deadline: default_deadline,
|
||||
});
|
||||
if cached_deadline.grace != startup_grace {
|
||||
*cached_deadline = OptionalStartupDeadline {
|
||||
grace: startup_grace,
|
||||
deadline: default_deadline,
|
||||
};
|
||||
}
|
||||
cached_deadline.deadline
|
||||
}
|
||||
|
||||
pub(crate) fn current_tools(&self) -> Option<Vec<ToolInfo>> {
|
||||
|
||||
Reference in new issue
Block a user