Fix fork cache build callsites

This commit is contained in:
Friel
2026-05-04 00:18:21 +00:00
parent c2db9386aa
commit d1ec95ec0e
6 changed files with 94 additions and 72 deletions
@@ -7,6 +7,7 @@
//! `codex-core`.
use std::collections::HashMap;
use std::future::Future;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
@@ -315,6 +316,34 @@ impl McpConnectionManager {
failures
}
pub fn required_startup_failures_future(
&self,
required_servers: Vec<String>,
) -> impl Future<Output = Vec<McpStartupFailure>> + Send + 'static {
let clients = self.clients.clone();
async move {
let mut failures = Vec::new();
for server_name in required_servers {
let Some(async_managed_client) = clients.get(&server_name).cloned() else {
failures.push(McpStartupFailure {
server: server_name.clone(),
error: format!("required MCP server `{server_name}` was not initialized"),
});
continue;
};
match async_managed_client.client().await {
Ok(_) => {}
Err(error) => failures.push(McpStartupFailure {
server: server_name.clone(),
error: startup_outcome_error_message(error),
}),
}
}
failures
}
}
/// Returns a single map that contains all tools. Each key is the
/// fully-qualified name for the tool.
#[instrument(level = "trace", skip_all)]
@@ -329,6 +358,22 @@ impl McpConnectionManager {
qualify_tools(tools)
}
pub fn list_all_tools_future(
&self,
) -> impl Future<Output = HashMap<String, ToolInfo>> + Send + 'static {
let clients = self.clients.values().cloned().collect::<Vec<_>>();
async move {
let mut tools = Vec::new();
for managed_client in clients {
let Some(server_tools) = managed_client.listed_tools().await else {
continue;
};
tools.extend(server_tools);
}
qualify_tools(tools)
}
}
/// Force-refresh codex apps tools by bypassing the in-process cache.
///
/// On success, the refreshed tools replace the cache contents and the