Let unrelated tools run while MCP servers start (#35937)

## Why

Cached MCP definitions can make a tool callable before its server has finished
starting. Waiting for that server while holding the tool execution gate blocks
unrelated calls in the same response.

## What changed

- Expose the owning MCP server through tool runtime metadata, including tools
  with exposure overrides.
- Refresh MCP state and wait for that specific server before entering the
  parallel execution gate.

## Testing

Extend the cached MCP tool regression test to verify that an unrelated plan
update completes while MCP startup remains pending.

GitOrigin-RevId: 884d154bc403dfc1d347d265da3d6a887948e7b6
This commit is contained in:
jif authored and copyberry committed 2026-07-29 11:14:16 +00:00
1 parent fe01054a28
commit fbf666fa98
7 files changed
+91 -6

No files matched your search

+13
View File
@@ -51,6 +51,11 @@ pub use codex_tools::ToolExposure;
/// Implementers provide the shared `ToolExecutor` behavior plus optional
/// core-owned metadata for hooks, telemetry, tool search, and argument diffs.
pub(crate) trait CoreToolRuntime: ToolExecutor<ToolInvocation> {
/// Returns the MCP server that owns this runtime, when this is an MCP tool.
fn mcp_server_name(&self) -> Option<&str> {
None
}
fn matches_kind(&self, payload: &ToolPayload) -> bool {
matches!(
payload,
@@ -283,6 +288,10 @@ impl ToolExecutor<ToolInvocation> for ExposureOverride {
}
impl CoreToolRuntime for ExposureOverride {
fn mcp_server_name(&self) -> Option<&str> {
self.handler.mcp_server_name()
}
fn matches_kind(&self, payload: &ToolPayload) -> bool {
self.handler.matches_kind(payload)
}
@@ -392,6 +401,10 @@ impl ToolRegistry {
self.tools.get(name).map(Arc::clone)
}
pub(crate) fn mcp_server_name(&self, name: &ToolName) -> Option<&str> {
self.tools.get(name)?.mcp_server_name()
}
#[cfg(test)]
pub(crate) fn tool_names_for_test(&self) -> Vec<ToolName> {
let mut names = self.tools.keys().cloned().collect::<Vec<_>>();