mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
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:
1 parent
b293412c24
commit
9a46fd33a0
7 files changed
+156
-34
No files matched your search
@@ -4,6 +4,7 @@ use std::time::Instant;
|
||||
use crate::function_tool::FunctionCallError;
|
||||
use crate::mcp_tool_call::handle_mcp_tool_call;
|
||||
use crate::original_image_detail::can_request_original_image_detail;
|
||||
use crate::session::session::Session;
|
||||
use crate::tools::context::McpToolOutput;
|
||||
use crate::tools::context::ToolInvocation;
|
||||
use crate::tools::context::ToolPayload;
|
||||
@@ -24,6 +25,7 @@ use codex_tools::ToolSearchSourceInfo;
|
||||
use codex_tools::ToolSpec;
|
||||
use codex_tools::mcp_tool_to_responses_api_tool;
|
||||
use codex_utils_string::take_bytes_at_char_boundary;
|
||||
use futures::future::BoxFuture;
|
||||
use serde_json::Map;
|
||||
use serde_json::Value;
|
||||
|
||||
@@ -166,14 +168,21 @@ impl McpHandler {
|
||||
}
|
||||
|
||||
impl CoreToolRuntime for McpHandler {
|
||||
fn mcp_server_name(&self) -> Option<&str> {
|
||||
Some(&self.tool_info.server_name)
|
||||
fn wait_until_ready<'a>(&'a self, session: &'a Arc<Session>) -> Option<BoxFuture<'a, ()>> {
|
||||
Some(Box::pin(async move {
|
||||
session.refresh_mcp_if_dirty().await;
|
||||
session
|
||||
.services
|
||||
.mcp_runtime
|
||||
.wait_for_server_startup(&self.tool_info.server_name)
|
||||
.await;
|
||||
}))
|
||||
}
|
||||
|
||||
fn telemetry_tags<'a>(
|
||||
&'a self,
|
||||
_invocation: &'a ToolInvocation,
|
||||
) -> futures::future::BoxFuture<'a, ToolTelemetryTags> {
|
||||
) -> BoxFuture<'a, ToolTelemetryTags> {
|
||||
Box::pin(async {
|
||||
let mut tags = vec![("mcp_server", self.tool_info.server_name.clone())];
|
||||
if let Some(origin) = &self.tool_info.server_origin {
|
||||
|
||||
Reference in new issue
Block a user