Delegate readiness waits to tool runtimes (#36120)

## What changed

- Add an optional `wait_until_ready` hook to `CoreToolRuntime` and invoke it
  before acquiring the tool execution gate.
- Move MCP refresh and server-startup waiting into the MCP runtime's hook.
- Forward readiness waits through tool exposure and namespace wrappers.
- Test exact runtime selection for plain and namespaced tools, including
  exposure overrides and missing tools.

GitOrigin-RevId: 8718589fa06f14d053a35a288186613f649d25ff
This commit is contained in:
jif authored and copyberry committed 2026-07-30 09:25:23 +00:00
1 parent b293412c24
commit 9a46fd33a0
7 files changed
+156 -34

No files matched your search

+21 -12
View File
@@ -181,15 +181,17 @@ async fn parallel_support_does_not_match_namespaced_local_tool_names() -> anyhow
.expect("test session should expose a parallel shell-like tool");
assert_eq!(
router.mcp_server_name(&ToolCall {
tool_name: ToolName::plain(parallel_tool_name),
call_id: "call-local-tool".to_string(),
payload: ToolPayload::Function {
arguments: "{}".to_string(),
},
encrypted_function_args: None,
}),
None
router
.tool_runtime(&ToolCall {
tool_name: ToolName::plain(parallel_tool_name),
call_id: "call-local-tool".to_string(),
payload: ToolPayload::Function {
arguments: "{}".to_string(),
},
encrypted_function_args: None,
})
.map(|runtime| runtime.tool_name()),
Some(ToolName::plain(parallel_tool_name))
);
assert!(!router.tool_supports_parallel(&ToolCall {
@@ -303,7 +305,12 @@ async fn mcp_parallel_support_uses_handler_data() -> anyhow::Result<()> {
encrypted_function_args: None,
};
assert!(router.tool_supports_parallel(&call));
assert_eq!(router.mcp_server_name(&call), Some("echo"));
assert_eq!(
router
.tool_runtime(&call)
.map(|runtime| runtime.tool_name()),
Some(call.tool_name.clone())
);
let different_server_call = ToolCall {
tool_name: ToolName::namespaced("mcp__hello_echo__", "query_with_delay"),
@@ -315,8 +322,10 @@ async fn mcp_parallel_support_uses_handler_data() -> anyhow::Result<()> {
};
assert!(!router.tool_supports_parallel(&different_server_call));
assert_eq!(
router.mcp_server_name(&different_server_call),
Some("hello_echo")
router
.tool_runtime(&different_server_call)
.map(|runtime| runtime.tool_name()),
Some(different_server_call.tool_name.clone())
);
Ok(())