From b445967cc0c3082376fc4c95c8101358213ccd7a Mon Sep 17 00:00:00 2001 From: jif Date: Thu, 30 Jul 2026 14:15:02 +0000 Subject: [PATCH] Make tool telemetry tag collection synchronous (#36168) ## What changed Return telemetry tags directly from `CoreToolRuntime::telemetry_tags` instead of wrapping them in a future, and update the MCP runtime and tool registry call site accordingly. GitOrigin-RevId: 54e03972fe23c0e644c68c73af504dba0871be8e --- codex-rs/core/src/tools/handlers/mcp.rs | 17 ++++++----------- codex-rs/core/src/tools/registry.rs | 14 ++++---------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/codex-rs/core/src/tools/handlers/mcp.rs b/codex-rs/core/src/tools/handlers/mcp.rs index 1ddb838b76..76124949f5 100644 --- a/codex-rs/core/src/tools/handlers/mcp.rs +++ b/codex-rs/core/src/tools/handlers/mcp.rs @@ -179,17 +179,12 @@ impl CoreToolRuntime for McpHandler { })) } - fn telemetry_tags<'a>( - &'a self, - _invocation: &'a ToolInvocation, - ) -> 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 { - tags.push(("mcp_server_origin", origin.clone())); - } - tags - }) + fn telemetry_tags(&self, _invocation: &ToolInvocation) -> ToolTelemetryTags { + let mut tags = vec![("mcp_server", self.tool_info.server_name.clone())]; + if let Some(origin) = &self.tool_info.server_origin { + tags.push(("mcp_server_origin", origin.clone())); + } + tags } fn pre_tool_use_payload(&self, invocation: &ToolInvocation) -> Option { diff --git a/codex-rs/core/src/tools/registry.rs b/codex-rs/core/src/tools/registry.rs index f5dddf0022..64b8e819d5 100644 --- a/codex-rs/core/src/tools/registry.rs +++ b/codex-rs/core/src/tools/registry.rs @@ -70,11 +70,8 @@ pub(crate) trait CoreToolRuntime: ToolExecutor { false } - fn telemetry_tags<'a>( - &'a self, - _invocation: &'a ToolInvocation, - ) -> BoxFuture<'a, ToolTelemetryTags> { - Box::pin(async { Vec::new() }) + fn telemetry_tags(&self, _invocation: &ToolInvocation) -> ToolTelemetryTags { + Vec::new() } fn post_tool_use_payload( @@ -322,10 +319,7 @@ impl CoreToolRuntime for ExposureOverride { .with_updated_hook_input(invocation, updated_input) } - fn telemetry_tags<'a>( - &'a self, - invocation: &'a ToolInvocation, - ) -> BoxFuture<'a, ToolTelemetryTags> { + fn telemetry_tags(&self, invocation: &ToolInvocation) -> ToolTelemetryTags { self.handler.telemetry_tags(invocation) } @@ -552,7 +546,7 @@ impl ToolRegistry { } }; - let telemetry_tags = tool.telemetry_tags(&invocation).await; + let telemetry_tags = tool.telemetry_tags(&invocation); let mut tool_result_tags = Vec::with_capacity(base_tool_result_tags.len() + telemetry_tags.len() + 1); let mut extra_trace_fields = Vec::new();