Lightweight coding agent that runs in your terminal
Rust
[codex] Remove async_trait from ToolExecutor (#27304)
Adam Perry @ OpenAI2704ecea9a1d
diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lockindex 17b2696cbf..51a6cd08cc 100644--- a/codex-rs/Cargo.lock+++ b/codex-rs/Cargo.lock@@ -3047,7 +3047,6 @@ name = "codex-goal-extension"version = "0.0.0"dependencies = ["anyhow",- "async-trait","chrono","codex-analytics","codex-core",@@ -3101,7 +3100,6 @@ dependencies = [name = "codex-image-generation-extension"version = "0.0.0"dependencies = [- "async-trait","codex-api","codex-core","codex-extension-api",@@ -3301,7 +3299,6 @@ dependencies = [name = "codex-memories-extension"version = "0.0.0"dependencies = [- "async-trait","codex-core","codex-extension-api","codex-features",@@ -3916,7 +3913,6 @@ dependencies = [name = "codex-tools"version = "0.0.0"dependencies = [- "async-trait","codex-app-server-protocol","codex-code-mode","codex-features",@@ -4297,7 +4293,6 @@ dependencies = [name = "codex-web-search-extension"version = "0.0.0"dependencies = [- "async-trait","codex-api","codex-core","codex-extension-api",diff --git a/codex-rs/core/src/tools/code_mode/execute_handler.rs b/codex-rs/core/src/tools/code_mode/execute_handler.rsindex 0bdb8b20a6..2e46c1bd6b 100644--- a/codex-rs/core/src/tools/code_mode/execute_handler.rs+++ b/codex-rs/core/src/tools/code_mode/execute_handler.rs@@ -91,7 +91,6 @@ impl CodeModeExecuteHandler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for CodeModeExecuteHandler {fn tool_name(&self) -> ToolName {ToolName::plain(PUBLIC_TOOL_NAME)@@ -101,11 +100,8 @@ impl ToolExecutor<ToolInvocation> for CodeModeExecuteHandler {self.spec.clone()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/code_mode/wait_handler.rs b/codex-rs/core/src/tools/code_mode/wait_handler.rsindex c1928955f4..953391a573 100644--- a/codex-rs/core/src/tools/code_mode/wait_handler.rs+++ b/codex-rs/core/src/tools/code_mode/wait_handler.rs@@ -44,7 +44,6 @@ where})}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for CodeModeWaitHandler {fn tool_name(&self) -> ToolName {ToolName::plain(WAIT_TOOL_NAME)@@ -54,11 +53,8 @@ impl ToolExecutor<ToolInvocation> for CodeModeWaitHandler {create_wait_tool()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/agent_jobs/report_agent_job_result.rs b/codex-rs/core/src/tools/handlers/agent_jobs/report_agent_job_result.rsindex 5f2a615329..579cc25ffb 100644--- a/codex-rs/core/src/tools/handlers/agent_jobs/report_agent_job_result.rs+++ b/codex-rs/core/src/tools/handlers/agent_jobs/report_agent_job_result.rs@@ -13,7 +13,6 @@ use super::*;pub struct ReportAgentJobResultHandler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ReportAgentJobResultHandler {fn tool_name(&self) -> ToolName {ToolName::plain("report_agent_job_result")@@ -23,11 +22,8 @@ impl ToolExecutor<ToolInvocation> for ReportAgentJobResultHandler {create_report_agent_job_result_tool()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/agent_jobs/spawn_agents_on_csv.rs b/codex-rs/core/src/tools/handlers/agent_jobs/spawn_agents_on_csv.rsindex 16e1b1f72c..6da517b9cc 100644--- a/codex-rs/core/src/tools/handlers/agent_jobs/spawn_agents_on_csv.rs+++ b/codex-rs/core/src/tools/handlers/agent_jobs/spawn_agents_on_csv.rs@@ -14,7 +14,6 @@ use super::*;pub struct SpawnAgentsOnCsvHandler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for SpawnAgentsOnCsvHandler {fn tool_name(&self) -> ToolName {ToolName::plain("spawn_agents_on_csv")@@ -24,11 +23,8 @@ impl ToolExecutor<ToolInvocation> for SpawnAgentsOnCsvHandler {create_spawn_agents_on_csv_tool()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/apply_patch.rs b/codex-rs/core/src/tools/handlers/apply_patch.rsindex 6a322ed6ae..70452b6657 100644--- a/codex-rs/core/src/tools/handlers/apply_patch.rs+++ b/codex-rs/core/src/tools/handlers/apply_patch.rs@@ -305,7 +305,6 @@ async fn effective_patch_permissions()}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ApplyPatchHandler {fn tool_name(&self) -> ToolName {ToolName::plain("apply_patch")@@ -315,11 +314,8 @@ impl ToolExecutor<ToolInvocation> for ApplyPatchHandler {create_apply_patch_freeform_tool(self.multi_environment)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/dynamic.rs b/codex-rs/core/src/tools/handlers/dynamic.rsindex e0151cf189..dabcea8e5a 100644--- a/codex-rs/core/src/tools/handlers/dynamic.rs+++ b/codex-rs/core/src/tools/handlers/dynamic.rs@@ -61,7 +61,6 @@ impl DynamicToolHandler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for DynamicToolHandler {fn tool_name(&self) -> ToolName {self.tool_name.clone()@@ -86,11 +85,8 @@ impl ToolExecutor<ToolInvocation> for DynamicToolHandler {)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/extension_tools.rs b/codex-rs/core/src/tools/handlers/extension_tools.rsindex a94c764a9f..d429b6c1fc 100644--- a/codex-rs/core/src/tools/handlers/extension_tools.rs+++ b/codex-rs/core/src/tools/handlers/extension_tools.rs@@ -11,13 +11,11 @@ use codex_tools::ToolSpec;use codex_tools::TurnItemEmissionFuture;use codex_tools::TurnItemEmitter;-use crate::function_tool::FunctionCallError;use crate::session::session::Session;use crate::session::turn_context::TurnContext;use crate::stream_events_utils::TurnItemContributorPolicy;use crate::stream_events_utils::finalize_turn_item;use crate::tools::context::ToolInvocation;-use crate::tools::context::ToolOutput;use crate::tools::context::ToolPayload;use crate::tools::registry::CoreToolRuntime;use crate::tools::registry::ToolExecutor;@@ -30,7 +28,6 @@ impl ExtensionToolAdapter {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ExtensionToolAdapter {fn tool_name(&self) -> ToolName {self.0.tool_name()@@ -52,11 +49,8 @@ impl ToolExecutor<ToolInvocation> for ExtensionToolAdapter {self.0.search_info()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn ToolOutput>, FunctionCallError> {- self.0.handle(to_extension_call(&invocation).await).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async move { self.0.handle(to_extension_call(&invocation).await).await })}}@@ -162,7 +156,6 @@ mod tests {struct StubExtensionExecutor;- #[async_trait::async_trait]impl codex_extension_api::ToolExecutor<codex_tools::ToolCall> for StubExtensionExecutor {fn tool_name(&self) -> codex_tools::ToolName {codex_tools::ToolName::plain("extension_echo")@@ -187,13 +180,13 @@ mod tests {})}- async fn handle(- &self,- _call: codex_tools::ToolCall,- ) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {- Ok(Box::new(codex_tools::JsonToolOutput::new(- json!({ "ok": true }),- )))+ fn handle(&self, _call: codex_tools::ToolCall) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async {+ Ok(+ Box::new(codex_tools::JsonToolOutput::new(json!({ "ok": true })))+ as Box<dyn codex_tools::ToolOutput>,+ )+ })}}@@ -201,7 +194,6 @@ mod tests {captured_call: Arc<Mutex<Option<codex_tools::ToolCall>>>,}- #[async_trait::async_trait]impl codex_extension_api::ToolExecutor<codex_tools::ToolCall> for CapturingExtensionExecutor {fn tool_name(&self) -> codex_tools::ToolName {codex_tools::ToolName::plain("extension_echo")@@ -218,11 +210,8 @@ mod tests {})}- async fn handle(- &self,- call: codex_tools::ToolCall,- ) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {- self.handle_call(call).await+ fn handle(&self, call: codex_tools::ToolCall) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}@@ -242,9 +231,10 @@ mod tests {call.turn_item_emitter.emit_started(item.clone()).await;call.turn_item_emitter.emit_completed(item).await;*self.captured_call.lock().await = Some(call);- Ok(Box::new(codex_tools::JsonToolOutput::new(- json!({ "ok": true }),- )))+ Ok(+ Box::new(codex_tools::JsonToolOutput::new(json!({ "ok": true })))+ as Box<dyn codex_tools::ToolOutput>,+ )}}@@ -441,7 +431,6 @@ mod tests {);}- #[async_trait::async_trait]impl codex_extension_api::ToolExecutor<codex_tools::ToolCall> for ImageGenerationExtensionExecutor {fn tool_name(&self) -> codex_tools::ToolName {codex_tools::ToolName::namespaced("image_gen", "imagegen")@@ -458,11 +447,8 @@ mod tests {})}- async fn handle(- &self,- call: codex_tools::ToolCall,- ) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {- self.handle_call(call).await+ fn handle(&self, call: codex_tools::ToolCall) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}@@ -493,9 +479,10 @@ mod tests {},)).await;- Ok(Box::new(codex_tools::JsonToolOutput::new(- json!({ "ok": true }),- )))+ Ok(+ Box::new(codex_tools::JsonToolOutput::new(json!({ "ok": true })))+ as Box<dyn codex_tools::ToolOutput>,+ )}}diff --git a/codex-rs/core/src/tools/handlers/list_available_plugins_to_install.rs b/codex-rs/core/src/tools/handlers/list_available_plugins_to_install.rsindex 2b782e4552..766b0e9b75 100644--- a/codex-rs/core/src/tools/handlers/list_available_plugins_to_install.rs+++ b/codex-rs/core/src/tools/handlers/list_available_plugins_to_install.rs@@ -54,7 +54,6 @@ impl ListAvailablePluginsToInstallHandler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ListAvailablePluginsToInstallHandler {fn tool_name(&self) -> ToolName {ToolName::plain(LIST_AVAILABLE_PLUGINS_TO_INSTALL_TOOL_NAME)@@ -68,11 +67,8 @@ impl ToolExecutor<ToolInvocation> for ListAvailablePluginsToInstallHandler {false}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/mcp.rs b/codex-rs/core/src/tools/handlers/mcp.rsindex d60cdfdd0c..efb32aab94 100644--- a/codex-rs/core/src/tools/handlers/mcp.rs+++ b/codex-rs/core/src/tools/handlers/mcp.rs@@ -64,7 +64,6 @@ fn ensure_mcp_prefix(name: &str) -> String {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for McpHandler {fn tool_name(&self) -> ToolName {self.tool_info.canonical_tool_name()@@ -113,11 +112,8 @@ impl ToolExecutor<ToolInvocation> for McpHandler {)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/mcp_resource/list_mcp_resource_templates.rs b/codex-rs/core/src/tools/handlers/mcp_resource/list_mcp_resource_templates.rsindex 8974d678fd..80b183daba 100644--- a/codex-rs/core/src/tools/handlers/mcp_resource/list_mcp_resource_templates.rs+++ b/codex-rs/core/src/tools/handlers/mcp_resource/list_mcp_resource_templates.rs@@ -26,7 +26,6 @@ use super::serialize_function_output;pub struct ListMcpResourceTemplatesHandler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ListMcpResourceTemplatesHandler {fn tool_name(&self) -> ToolName {ToolName::plain("list_mcp_resource_templates")@@ -40,11 +39,8 @@ impl ToolExecutor<ToolInvocation> for ListMcpResourceTemplatesHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/mcp_resource/list_mcp_resources.rs b/codex-rs/core/src/tools/handlers/mcp_resource/list_mcp_resources.rsindex f3a7b43c28..a77d617b94 100644--- a/codex-rs/core/src/tools/handlers/mcp_resource/list_mcp_resources.rs+++ b/codex-rs/core/src/tools/handlers/mcp_resource/list_mcp_resources.rs@@ -26,7 +26,6 @@ use super::serialize_function_output;pub struct ListMcpResourcesHandler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ListMcpResourcesHandler {fn tool_name(&self) -> ToolName {ToolName::plain("list_mcp_resources")@@ -40,11 +39,8 @@ impl ToolExecutor<ToolInvocation> for ListMcpResourcesHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/mcp_resource/read_mcp_resource.rs b/codex-rs/core/src/tools/handlers/mcp_resource/read_mcp_resource.rsindex 9861e5d22d..9ca15718a0 100644--- a/codex-rs/core/src/tools/handlers/mcp_resource/read_mcp_resource.rs+++ b/codex-rs/core/src/tools/handlers/mcp_resource/read_mcp_resource.rs@@ -26,7 +26,6 @@ use super::serialize_function_output;pub struct ReadMcpResourceHandler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ReadMcpResourceHandler {fn tool_name(&self) -> ToolName {ToolName::plain("read_mcp_resource")@@ -40,11 +39,8 @@ impl ToolExecutor<ToolInvocation> for ReadMcpResourceHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents/close_agent.rs b/codex-rs/core/src/tools/handlers/multi_agents/close_agent.rsindex 0d4e17447d..d1017adb65 100644--- a/codex-rs/core/src/tools/handlers/multi_agents/close_agent.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents/close_agent.rs@@ -6,7 +6,6 @@ use codex_tools::ToolSpec;pub(crate) struct Handler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::namespaced(MULTI_AGENT_V1_NAMESPACE, "close_agent")@@ -23,11 +22,8 @@ impl ToolExecutor<ToolInvocation> for Handler {)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- handle_close_agent(invocation).await.map(boxed_tool_output)+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async move { handle_close_agent(invocation).await.map(boxed_tool_output) })}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents/resume_agent.rs b/codex-rs/core/src/tools/handlers/multi_agents/resume_agent.rsindex 8f95abe4e3..fa464ddbbb 100644--- a/codex-rs/core/src/tools/handlers/multi_agents/resume_agent.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents/resume_agent.rs@@ -7,7 +7,6 @@ use std::sync::Arc;pub(crate) struct Handler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::namespaced(MULTI_AGENT_V1_NAMESPACE, "resume_agent")@@ -24,11 +23,8 @@ impl ToolExecutor<ToolInvocation> for Handler {)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- handle_resume_agent(invocation).await.map(boxed_tool_output)+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async move { handle_resume_agent(invocation).await.map(boxed_tool_output) })}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents/send_input.rs b/codex-rs/core/src/tools/handlers/multi_agents/send_input.rsindex b811faf91a..375bb50ac7 100644--- a/codex-rs/core/src/tools/handlers/multi_agents/send_input.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents/send_input.rs@@ -6,7 +6,6 @@ use codex_tools::ToolSpec;pub(crate) struct Handler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::namespaced(MULTI_AGENT_V1_NAMESPACE, "send_input")@@ -23,11 +22,8 @@ impl ToolExecutor<ToolInvocation> for Handler {)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents/spawn.rs b/codex-rs/core/src/tools/handlers/multi_agents/spawn.rsindex 3f6c97fcbc..204385934e 100644--- a/codex-rs/core/src/tools/handlers/multi_agents/spawn.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents/spawn.rs@@ -22,7 +22,6 @@ impl Handler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::namespaced(MULTI_AGENT_V1_NAMESPACE, "spawn_agent")@@ -39,11 +38,8 @@ impl ToolExecutor<ToolInvocation> for Handler {)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- handle_spawn_agent(invocation).await.map(boxed_tool_output)+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async move { handle_spawn_agent(invocation).await.map(boxed_tool_output) })}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents/wait.rs b/codex-rs/core/src/tools/handlers/multi_agents/wait.rsindex 1f6b7db8f1..be22b36908 100644--- a/codex-rs/core/src/tools/handlers/multi_agents/wait.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents/wait.rs@@ -27,7 +27,6 @@ impl Handler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::namespaced(MULTI_AGENT_V1_NAMESPACE, "wait_agent")@@ -44,11 +43,8 @@ impl ToolExecutor<ToolInvocation> for Handler {)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/followup_task.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/followup_task.rsindex 66a39cc79d..bd4dafe7c2 100644--- a/codex-rs/core/src/tools/handlers/multi_agents_v2/followup_task.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/followup_task.rs@@ -7,7 +7,6 @@ use codex_tools::ToolSpec;pub(crate) struct Handler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::plain("followup_task")@@ -17,11 +16,8 @@ impl ToolExecutor<ToolInvocation> for Handler {create_followup_task_tool()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/interrupt_agent.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/interrupt_agent.rsindex 159c49127a..aeed055b4e 100644--- a/codex-rs/core/src/tools/handlers/multi_agents_v2/interrupt_agent.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/interrupt_agent.rs@@ -6,7 +6,6 @@ use codex_tools::ToolSpec;pub(crate) struct Handler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::plain("interrupt_agent")@@ -16,13 +15,12 @@ impl ToolExecutor<ToolInvocation> for Handler {create_interrupt_agent_tool_v2()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- handle_interrupt_agent(invocation)- .await- .map(boxed_tool_output)+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async move {+ handle_interrupt_agent(invocation)+ .await+ .map(boxed_tool_output)+ })}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/list_agents.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/list_agents.rsindex 18421278fe..99e54e1ce9 100644--- a/codex-rs/core/src/tools/handlers/multi_agents_v2/list_agents.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/list_agents.rs@@ -5,7 +5,6 @@ use codex_tools::ToolSpec;pub(crate) struct Handler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::plain("list_agents")@@ -15,11 +14,8 @@ impl ToolExecutor<ToolInvocation> for Handler {create_list_agents_tool()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/send_message.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/send_message.rsindex 2fd636a85c..717e3bc920 100644--- a/codex-rs/core/src/tools/handlers/multi_agents_v2/send_message.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/send_message.rs@@ -7,7 +7,6 @@ use codex_tools::ToolSpec;pub(crate) struct Handler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::plain("send_message")@@ -17,11 +16,8 @@ impl ToolExecutor<ToolInvocation> for Handler {create_send_message_tool()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rsindex 34fddc60b4..2186a4a6d6 100644--- a/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs@@ -22,7 +22,6 @@ impl Handler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::plain("spawn_agent")@@ -32,11 +31,8 @@ impl ToolExecutor<ToolInvocation> for Handler {create_spawn_agent_tool_v2(self.options.clone())}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- handle_spawn_agent(invocation).await.map(boxed_tool_output)+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async move { handle_spawn_agent(invocation).await.map(boxed_tool_output) })}}diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rsindex 9d671b1989..36e5aa24f6 100644--- a/codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs+++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/wait.rs@@ -19,7 +19,6 @@ impl Handler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for Handler {fn tool_name(&self) -> ToolName {ToolName::plain("wait_agent")@@ -29,11 +28,8 @@ impl ToolExecutor<ToolInvocation> for Handler {create_wait_agent_tool_v2(self.options)}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/plan.rs b/codex-rs/core/src/tools/handlers/plan.rsindex ff18a32813..1b30c281ce 100644--- a/codex-rs/core/src/tools/handlers/plan.rs+++ b/codex-rs/core/src/tools/handlers/plan.rs@@ -45,7 +45,6 @@ impl ToolOutput for PlanToolOutput {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for PlanHandler {fn tool_name(&self) -> ToolName {ToolName::plain("update_plan")@@ -55,11 +54,8 @@ impl ToolExecutor<ToolInvocation> for PlanHandler {create_update_plan_tool()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/request_permissions.rs b/codex-rs/core/src/tools/handlers/request_permissions.rsindex 7c24f15697..4faf9d328b 100644--- a/codex-rs/core/src/tools/handlers/request_permissions.rs+++ b/codex-rs/core/src/tools/handlers/request_permissions.rs@@ -25,7 +25,6 @@ struct RequestPermissionsEnvironmentArgs {environment_id: Option<String>,}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for RequestPermissionsHandler {fn tool_name(&self) -> ToolName {ToolName::plain("request_permissions")@@ -35,11 +34,8 @@ impl ToolExecutor<ToolInvocation> for RequestPermissionsHandler {create_request_permissions_tool(request_permissions_tool_description())}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/request_plugin_install.rs b/codex-rs/core/src/tools/handlers/request_plugin_install.rsindex 64625aaac0..801031348f 100644--- a/codex-rs/core/src/tools/handlers/request_plugin_install.rs+++ b/codex-rs/core/src/tools/handlers/request_plugin_install.rs@@ -48,7 +48,6 @@ impl RequestPluginInstallHandler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for RequestPluginInstallHandler {fn tool_name(&self) -> ToolName {ToolName::plain(REQUEST_PLUGIN_INSTALL_TOOL_NAME)@@ -62,11 +61,8 @@ impl ToolExecutor<ToolInvocation> for RequestPluginInstallHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/request_user_input.rs b/codex-rs/core/src/tools/handlers/request_user_input.rsindex 3f3adf0ba3..4f26865a68 100644--- a/codex-rs/core/src/tools/handlers/request_user_input.rs+++ b/codex-rs/core/src/tools/handlers/request_user_input.rs@@ -20,7 +20,6 @@ pub struct RequestUserInputHandler {pub available_modes: Vec<ModeKind>,}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for RequestUserInputHandler {fn tool_name(&self) -> ToolName {ToolName::plain(REQUEST_USER_INPUT_TOOL_NAME)@@ -30,11 +29,8 @@ impl ToolExecutor<ToolInvocation> for RequestUserInputHandler {create_request_user_input_tool(request_user_input_tool_description(&self.available_modes))}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/shell/shell_command.rs b/codex-rs/core/src/tools/handlers/shell/shell_command.rsindex e9fcf82046..b754187d4a 100644--- a/codex-rs/core/src/tools/handlers/shell/shell_command.rs+++ b/codex-rs/core/src/tools/handlers/shell/shell_command.rs@@ -124,7 +124,6 @@ impl From<ShellCommandBackendConfig> for ShellCommandHandler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ShellCommandHandler {fn tool_name(&self) -> ToolName {ToolName::plain("shell_command")@@ -141,11 +140,8 @@ impl ToolExecutor<ToolInvocation> for ShellCommandHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/test_sync.rs b/codex-rs/core/src/tools/handlers/test_sync.rsindex 802859c916..08d983b616 100644--- a/codex-rs/core/src/tools/handlers/test_sync.rs+++ b/codex-rs/core/src/tools/handlers/test_sync.rs@@ -57,7 +57,6 @@ fn barrier_map() -> &'static tokio::sync::Mutex<HashMap<String, BarrierState>> {BARRIERS.get_or_init(|| tokio::sync::Mutex::new(HashMap::new()))}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for TestSyncHandler {fn tool_name(&self) -> ToolName {ToolName::plain("test_sync_tool")@@ -71,11 +70,8 @@ impl ToolExecutor<ToolInvocation> for TestSyncHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/tool_search.rs b/codex-rs/core/src/tools/handlers/tool_search.rsindex a4781e75e2..9254f4bee0 100644--- a/codex-rs/core/src/tools/handlers/tool_search.rs+++ b/codex-rs/core/src/tools/handlers/tool_search.rs@@ -53,7 +53,6 @@ impl ToolSearchHandler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ToolSearchHandler {fn tool_name(&self) -> ToolName {ToolName::plain(TOOL_SEARCH_TOOL_NAME)@@ -67,11 +66,8 @@ impl ToolExecutor<ToolInvocation> for ToolSearchHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs b/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rsindex 9fe3b343b5..7c914deb4f 100644--- a/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs+++ b/codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs@@ -71,7 +71,6 @@ impl ExecCommandHandler {}}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ExecCommandHandler {fn tool_name(&self) -> ToolName {ToolName::plain("exec_command")@@ -92,11 +91,8 @@ impl ToolExecutor<ToolInvocation> for ExecCommandHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs b/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rsindex 9b319d5433..8ddce65840 100644--- a/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs+++ b/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs@@ -31,7 +31,6 @@ struct WriteStdinArgs {pub struct WriteStdinHandler;-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for WriteStdinHandler {fn tool_name(&self) -> ToolName {ToolName::plain("write_stdin")@@ -41,11 +40,8 @@ impl ToolExecutor<ToolInvocation> for WriteStdinHandler {create_write_stdin_tool()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/handlers/view_image.rs b/codex-rs/core/src/tools/handlers/view_image.rsindex eb761359a7..0432ad338f 100644--- a/codex-rs/core/src/tools/handlers/view_image.rs+++ b/codex-rs/core/src/tools/handlers/view_image.rs@@ -64,7 +64,6 @@ enum ViewImageDetail {Original,}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ViewImageHandler {fn tool_name(&self) -> ToolName {ToolName::plain("view_image")@@ -78,11 +77,8 @@ impl ToolExecutor<ToolInvocation> for ViewImageHandler {true}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}diff --git a/codex-rs/core/src/tools/parallel.rs b/codex-rs/core/src/tools/parallel.rsindex a6f630a342..c40886b56c 100644--- a/codex-rs/core/src/tools/parallel.rs+++ b/codex-rs/core/src/tools/parallel.rs@@ -257,7 +257,6 @@ mod tests {tool_name: codex_tools::ToolName,}- #[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ImmediateHandler {fn tool_name(&self) -> codex_tools::ToolName {self.tool_name.clone()@@ -274,14 +273,13 @@ mod tests {})}- async fn handle(- &self,- _invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- Ok(Box::new(FunctionToolOutput::from_text(- "ok".to_string(),- Some(true),- )))+ fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async {+ Ok(+ Box::new(FunctionToolOutput::from_text("ok".to_string(), Some(true)))+ as Box<dyn crate::tools::context::ToolOutput>,+ )+ })}}@@ -294,7 +292,6 @@ mod tests {allow_cleanup: Arc<Notify>,}- #[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for CancellationCleanupHandler {fn tool_name(&self) -> codex_tools::ToolName {self.tool_name.clone()@@ -311,11 +308,8 @@ mod tests {})}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(invocation))}}@@ -345,7 +339,7 @@ mod tests {Ok(Box::new(FunctionToolOutput::from_text("cleanup complete".to_string(),Some(false),- )))+ )) as Box<dyn crate::tools::context::ToolOutput>)}}diff --git a/codex-rs/core/src/tools/registry.rs b/codex-rs/core/src/tools/registry.rsindex 20e08e9f7d..76e3f5f341 100644--- a/codex-rs/core/src/tools/registry.rs+++ b/codex-rs/core/src/tools/registry.rs@@ -250,7 +250,6 @@ struct ExposureOverride {exposure: ToolExposure,}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for ExposureOverride {fn tool_name(&self) -> ToolName {self.handler.tool_name()@@ -272,11 +271,8 @@ impl ToolExecutor<ToolInvocation> for ExposureOverride {self.handler.search_info()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn ToolOutput>, FunctionCallError> {- self.handler.handle(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ self.handler.handle(invocation)}}diff --git a/codex-rs/core/src/tools/registry_tests.rs b/codex-rs/core/src/tools/registry_tests.rsindex cc7f39e2a3..67613f1d08 100644--- a/codex-rs/core/src/tools/registry_tests.rs+++ b/codex-rs/core/src/tools/registry_tests.rs@@ -5,7 +5,6 @@ struct TestHandler {tool_name: codex_tools::ToolName,}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for TestHandler {fn tool_name(&self) -> codex_tools::ToolName {self.tool_name.clone()@@ -15,13 +14,15 @@ impl ToolExecutor<ToolInvocation> for TestHandler {test_spec(&self.tool_name)}- async fn handle(- &self,- _invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- Ok(Box::new(- crate::tools::context::FunctionToolOutput::from_text("ok".to_string(), Some(true)),- ))+ fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async {+ Ok(+ Box::new(crate::tools::context::FunctionToolOutput::from_text(+ "ok".to_string(),+ Some(true),+ )) as Box<dyn crate::tools::context::ToolOutput>,+ )+ })}}@@ -38,7 +39,6 @@ struct LifecycleTestHandler {result: LifecycleTestResult,}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for LifecycleTestHandler {fn tool_name(&self) -> codex_tools::ToolName {self.tool_name.clone()@@ -48,11 +48,8 @@ impl ToolExecutor<ToolInvocation> for LifecycleTestHandler {test_spec(&self.tool_name)}- async fn handle(- &self,- _invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- self.handle_call().await+ fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call())}}@@ -66,7 +63,8 @@ impl LifecycleTestHandler {"ok".to_string(),Some(success),),- )),+ )+ as Box<dyn crate::tools::context::ToolOutput>),LifecycleTestResult::Err => Err(FunctionCallError::RespondToModel("handler failed".to_string(),)),diff --git a/codex-rs/core/src/tools/router_tests.rs b/codex-rs/core/src/tools/router_tests.rsindex a9a52ca463..4024cb61f7 100644--- a/codex-rs/core/src/tools/router_tests.rs+++ b/codex-rs/core/src/tools/router_tests.rs@@ -44,7 +44,6 @@ impl codex_extension_api::ToolContributor for ExtensionEchoContributor {struct ExtensionEchoExecutor;-#[async_trait::async_trait]impl ToolExecutor<ExtensionToolCall> for ExtensionEchoExecutor {fn tool_name(&self) -> ToolName {ToolName::namespaced("extension/", "echo")@@ -73,11 +72,8 @@ impl ToolExecutor<ExtensionToolCall> for ExtensionEchoExecutor {})}- async fn handle(- &self,- call: ExtensionToolCall,- ) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {- self.handle_call(call).await+ fn handle(&self, call: ExtensionToolCall) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}@@ -93,7 +89,7 @@ impl ExtensionEchoExecutor {"callId": call.call_id,"conversationHistory": call.conversation_history.items(),"ok": true,- }))))+ }))) as Box<dyn codex_tools::ToolOutput>)}}diff --git a/codex-rs/core/src/tools/spec_plan.rs b/codex-rs/core/src/tools/spec_plan.rsindex 19f4c9f897..697eba1d4a 100644--- a/codex-rs/core/src/tools/spec_plan.rs+++ b/codex-rs/core/src/tools/spec_plan.rs@@ -72,7 +72,6 @@ use codex_tools::ToolCall as ExtensionToolCall;use codex_tools::ToolEnvironmentMode;use codex_tools::ToolExecutor;use codex_tools::ToolName;-use codex_tools::ToolOutput;use codex_tools::ToolSearchInfo;use codex_tools::ToolSpec;use codex_tools::UnifiedExecShellMode;@@ -946,7 +945,6 @@ struct MultiAgentV2NamespaceOverride {namespace: String,}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for MultiAgentV2NamespaceOverride {fn tool_name(&self) -> ToolName {ToolName::namespaced(self.namespace.clone(), self.handler.tool_name().name)@@ -975,11 +973,8 @@ impl ToolExecutor<ToolInvocation> for MultiAgentV2NamespaceOverride {self.handler.search_info()}- async fn handle(- &self,- invocation: ToolInvocation,- ) -> Result<Box<dyn ToolOutput>, codex_tools::FunctionCallError> {- self.handler.handle(invocation).await+ fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ self.handler.handle(invocation)}}diff --git a/codex-rs/core/src/tools/spec_plan_tests.rs b/codex-rs/core/src/tools/spec_plan_tests.rsindex f96f41f0f2..a9eb5012d5 100644--- a/codex-rs/core/src/tools/spec_plan_tests.rs+++ b/codex-rs/core/src/tools/spec_plan_tests.rs@@ -285,7 +285,6 @@ fn use_bedrock_provider(turn: &mut TurnContext) {struct WebRunExtensionTool;-#[async_trait::async_trait]impl ToolExecutor<ExtensionToolCall> for WebRunExtensionTool {fn tool_name(&self) -> ToolName {ToolName::namespaced("web", "run")@@ -306,17 +305,15 @@ impl ToolExecutor<ExtensionToolCall> for WebRunExtensionTool {})}- async fn handle(- &self,- _call: ExtensionToolCall,- ) -> Result<Box<dyn ToolOutput>, codex_tools::FunctionCallError> {- Ok(Box::new(codex_tools::JsonToolOutput::new(json!({}))))+ fn handle(&self, _call: ExtensionToolCall) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async {+ Ok(Box::new(codex_tools::JsonToolOutput::new(json!({}))) as Box<dyn ToolOutput>)+ })}}struct DeferredExtensionTool;-#[async_trait::async_trait]impl ToolExecutor<ExtensionToolCall> for DeferredExtensionTool {fn tool_name(&self) -> ToolName {ToolName::plain("extension_echo")@@ -344,11 +341,8 @@ impl ToolExecutor<ExtensionToolCall> for DeferredExtensionTool {ToolExposure::Deferred}- async fn handle(- &self,- _call: ExtensionToolCall,- ) -> Result<Box<dyn ToolOutput>, codex_tools::FunctionCallError> {- panic!("spec planning should not execute extension tools")+ fn handle(&self, _call: ExtensionToolCall) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async { panic!("spec planning should not execute extension tools") })}}diff --git a/codex-rs/core/src/tools/tool_dispatch_trace_tests.rs b/codex-rs/core/src/tools/tool_dispatch_trace_tests.rsindex 69dc8ab580..b09996872e 100644--- a/codex-rs/core/src/tools/tool_dispatch_trace_tests.rs+++ b/codex-rs/core/src/tools/tool_dispatch_trace_tests.rs@@ -30,7 +30,6 @@ struct TestHandler {tool_name: codex_tools::ToolName,}-#[async_trait::async_trait]impl ToolExecutor<ToolInvocation> for TestHandler {fn tool_name(&self) -> codex_tools::ToolName {self.tool_name.clone()@@ -47,14 +46,13 @@ impl ToolExecutor<ToolInvocation> for TestHandler {})}- async fn handle(- &self,- _invocation: ToolInvocation,- ) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {- Ok(Box::new(FunctionToolOutput::from_text(- "ok".to_string(),- Some(true),- )))+ fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {+ Box::pin(async {+ Ok(+ Box::new(FunctionToolOutput::from_text("ok".to_string(), Some(true)))+ as Box<dyn crate::tools::context::ToolOutput>,+ )+ })}}diff --git a/codex-rs/ext/extension-api/src/lib.rs b/codex-rs/ext/extension-api/src/lib.rsindex dc3495a71c..52f15c894c 100644--- a/codex-rs/ext/extension-api/src/lib.rs+++ b/codex-rs/ext/extension-api/src/lib.rs@@ -20,6 +20,7 @@ pub use codex_tools::NoopTurnItemEmitter;pub use codex_tools::ResponsesApiTool;pub use codex_tools::ToolCall;pub use codex_tools::ToolExecutor;+pub use codex_tools::ToolExecutorFuture;pub use codex_tools::ToolName;pub use codex_tools::ToolOutput;pub use codex_tools::ToolPayload;diff --git a/codex-rs/ext/goal/Cargo.toml b/codex-rs/ext/goal/Cargo.tomlindex 1e21f5ac88..4d75ba2f26 100644--- a/codex-rs/ext/goal/Cargo.toml+++ b/codex-rs/ext/goal/Cargo.toml@@ -14,7 +14,6 @@ doctest = falseworkspace = true[dependencies]-async-trait = { workspace = true }codex-analytics = { workspace = true }codex-core = { workspace = true }codex-extension-api = { workspace = true }diff --git a/codex-rs/ext/goal/src/tool.rs b/codex-rs/ext/goal/src/tool.rsindex c45ed81b0a..d280f6e04b 100644--- a/codex-rs/ext/goal/src/tool.rs+++ b/codex-rs/ext/goal/src/tool.rs@@ -1,6 +1,5 @@use std::sync::Arc;-use async_trait::async_trait;use codex_extension_api::FunctionCallError;use codex_extension_api::JsonToolOutput;use codex_extension_api::ToolCall;@@ -132,7 +131,6 @@ impl GoalToolExecutor {}}-#[async_trait]impl ToolExecutor<ToolCall> for GoalToolExecutor {fn tool_name(&self) -> ToolName {ToolName::plain(match self.kind {@@ -150,12 +148,14 @@ impl ToolExecutor<ToolCall> for GoalToolExecutor {}}- async fn handle(&self, invocation: ToolCall) -> Result<Box<dyn ToolOutput>, FunctionCallError> {- match self.kind {- GoalToolKind::Get => self.handle_get(invocation).await,- GoalToolKind::Create => self.handle_create(invocation).await,- GoalToolKind::Update => self.handle_update(invocation).await,- }+ fn handle(&self, invocation: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {+ Box::pin(async move {+ match self.kind {+ GoalToolKind::Get => self.handle_get(invocation).await,+ GoalToolKind::Create => self.handle_create(invocation).await,+ GoalToolKind::Update => self.handle_update(invocation).await,+ }+ })}}diff --git a/codex-rs/ext/image-generation/Cargo.toml b/codex-rs/ext/image-generation/Cargo.tomlindex cb5ddda0a8..dfa85ee82e 100644--- a/codex-rs/ext/image-generation/Cargo.toml+++ b/codex-rs/ext/image-generation/Cargo.toml@@ -13,7 +13,6 @@ doctest = falseworkspace = true[dependencies]-async-trait = { workspace = true }codex-api = { workspace = true }codex-core = { workspace = true }codex-extension-api = { workspace = true }diff --git a/codex-rs/ext/image-generation/src/tool.rs b/codex-rs/ext/image-generation/src/tool.rsindex 70880b4661..07ed8f4bf6 100644--- a/codex-rs/ext/image-generation/src/tool.rs+++ b/codex-rs/ext/image-generation/src/tool.rs@@ -78,7 +78,6 @@ struct ImagegenArgs {num_last_images_to_include: Option<usize>,}-#[async_trait::async_trait]impl ToolExecutor<ToolCall> for ImageGenerationTool {/// Keeps the tool in the existing image-generation Responses namespace.fn tool_name(&self) -> ToolName {@@ -96,8 +95,8 @@ impl ToolExecutor<ToolCall> for ImageGenerationTool {}/// Executes the selected image operation and returns the completed image result.- async fn handle(&self, call: ToolCall) -> Result<Box<dyn ToolOutput>, FunctionCallError> {- self.handle_call(call).await+ fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}diff --git a/codex-rs/ext/memories/Cargo.toml b/codex-rs/ext/memories/Cargo.tomlindex 68eeaf8ec1..e283140b15 100644--- a/codex-rs/ext/memories/Cargo.toml+++ b/codex-rs/ext/memories/Cargo.toml@@ -13,7 +13,6 @@ doctest = falseworkspace = true[dependencies]-async-trait = { workspace = true }codex-core = { workspace = true }codex-extension-api = { workspace = true }codex-features = { workspace = true }diff --git a/codex-rs/ext/memories/src/tools/ad_hoc_note.rs b/codex-rs/ext/memories/src/tools/ad_hoc_note.rsindex 3495d57d32..0ce9cade67 100644--- a/codex-rs/ext/memories/src/tools/ad_hoc_note.rs+++ b/codex-rs/ext/memories/src/tools/ad_hoc_note.rs@@ -41,7 +41,6 @@ pub(super) struct AddAdHocNoteTool<B> {pub(super) metrics_client: Option<MetricsClient>,}-#[async_trait::async_trait]impl<B> ToolExecutor<ToolCall> for AddAdHocNoteTool<B>whereB: MemoriesBackend,@@ -57,12 +56,8 @@ where)}- async fn handle(- &self,- call: ToolCall,- ) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>- {- self.handle_call(call).await+ fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}diff --git a/codex-rs/ext/memories/src/tools/list.rs b/codex-rs/ext/memories/src/tools/list.rsindex d3b23b1ca2..b7b9ad0586 100644--- a/codex-rs/ext/memories/src/tools/list.rs+++ b/codex-rs/ext/memories/src/tools/list.rs@@ -39,7 +39,6 @@ pub(super) struct ListTool<B> {pub(super) metrics_client: Option<MetricsClient>,}-#[async_trait::async_trait]impl<B> ToolExecutor<ToolCall> for ListTool<B>whereB: MemoriesBackend,@@ -55,12 +54,8 @@ where)}- async fn handle(- &self,- call: ToolCall,- ) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>- {- self.handle_call(call).await+ fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}diff --git a/codex-rs/ext/memories/src/tools/read.rs b/codex-rs/ext/memories/src/tools/read.rsindex e408a17cad..6625cdaf8b 100644--- a/codex-rs/ext/memories/src/tools/read.rs+++ b/codex-rs/ext/memories/src/tools/read.rs@@ -38,7 +38,6 @@ pub(super) struct ReadTool<B> {pub(super) metrics_client: Option<MetricsClient>,}-#[async_trait::async_trait]impl<B> ToolExecutor<ToolCall> for ReadTool<B>whereB: MemoriesBackend,@@ -54,12 +53,8 @@ where)}- async fn handle(- &self,- call: ToolCall,- ) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>- {- self.handle_call(call).await+ fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}diff --git a/codex-rs/ext/memories/src/tools/search.rs b/codex-rs/ext/memories/src/tools/search.rsindex cc8ba201a6..928c98b475 100644--- a/codex-rs/ext/memories/src/tools/search.rs+++ b/codex-rs/ext/memories/src/tools/search.rs@@ -47,7 +47,6 @@ pub(super) struct SearchTool<B> {pub(super) metrics_client: Option<MetricsClient>,}-#[async_trait::async_trait]impl<B> ToolExecutor<ToolCall> for SearchTool<B>whereB: MemoriesBackend,@@ -63,12 +62,8 @@ where)}- async fn handle(- &self,- call: ToolCall,- ) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>- {- self.handle_call(call).await+ fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}diff --git a/codex-rs/ext/web-search/Cargo.toml b/codex-rs/ext/web-search/Cargo.tomlindex 954ac3dac9..d007d6146d 100644--- a/codex-rs/ext/web-search/Cargo.toml+++ b/codex-rs/ext/web-search/Cargo.toml@@ -13,7 +13,6 @@ doctest = falseworkspace = true[dependencies]-async-trait = { workspace = true }codex-api = { workspace = true }codex-core = { workspace = true }codex-extension-api = { workspace = true }diff --git a/codex-rs/ext/web-search/src/tool.rs b/codex-rs/ext/web-search/src/tool.rsindex 1de65edf86..9b8dbf56d6 100644--- a/codex-rs/ext/web-search/src/tool.rs+++ b/codex-rs/ext/web-search/src/tool.rs@@ -39,7 +39,6 @@ pub(crate) struct WebSearchTool {pub(crate) settings: SearchSettings,}-#[async_trait::async_trait]impl ToolExecutor<ToolCall> for WebSearchTool {fn tool_name(&self) -> ToolName {ToolName::namespaced(WEB_NAMESPACE, RUN_TOOL_NAME)@@ -74,8 +73,8 @@ impl ToolExecutor<ToolCall> for WebSearchTool {true}- async fn handle(&self, call: ToolCall) -> Result<Box<dyn ToolOutput>, FunctionCallError> {- self.handle_call(call).await+ fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {+ Box::pin(self.handle_call(call))}}diff --git a/codex-rs/tools/Cargo.toml b/codex-rs/tools/Cargo.tomlindex 7cc0e34845..4b2a3257f3 100644--- a/codex-rs/tools/Cargo.toml+++ b/codex-rs/tools/Cargo.toml@@ -8,7 +8,6 @@ version.workspace = trueworkspace = true[dependencies]-async-trait = { workspace = true }codex-app-server-protocol = { workspace = true }codex-code-mode = { workspace = true }codex-features = { workspace = true }diff --git a/codex-rs/tools/src/lib.rs b/codex-rs/tools/src/lib.rsindex 1cee3f7d2d..848bab3e1c 100644--- a/codex-rs/tools/src/lib.rs+++ b/codex-rs/tools/src/lib.rs@@ -93,6 +93,7 @@ pub use tool_discovery::ToolSearchSourceInfo;pub use tool_discovery::collect_request_plugin_install_entries;pub use tool_discovery::filter_request_plugin_install_discoverable_tools_for_client;pub use tool_executor::ToolExecutor;+pub use tool_executor::ToolExecutorFuture;pub use tool_executor::ToolExposure;pub use tool_output::JsonToolOutput;pub use tool_output::ToolOutput;diff --git a/codex-rs/tools/src/tool_executor.rs b/codex-rs/tools/src/tool_executor.rsindex 541d2443e0..708ed1c3b1 100644--- a/codex-rs/tools/src/tool_executor.rs+++ b/codex-rs/tools/src/tool_executor.rs@@ -3,6 +3,12 @@ use crate::ToolName;use crate::ToolOutput;use crate::ToolSearchInfo;use crate::ToolSpec;+use std::future::Future;+use std::pin::Pin;++/// The boxed future returned by [`ToolExecutor::handle`].+pub type ToolExecutorFuture<'a> =+ Pin<Box<dyn Future<Output = Result<Box<dyn ToolOutput>, FunctionCallError>> + Send + 'a>>;/// Controls where a tool is exposed to the model.#[derive(Clone, Copy, Debug, Eq, PartialEq)]@@ -40,7 +46,6 @@ impl ToolExposure {/// Implementations keep the model-visible spec tied to the executable runtime./// Host crates can layer routing, hooks, telemetry, or other orchestration on/// top without reopening the spec/runtime split.-#[async_trait::async_trait]pub trait ToolExecutor<Invocation>: Send + Sync {/// The concrete tool name handled by this runtime instance.fn tool_name(&self) -> ToolName;@@ -60,8 +65,5 @@ pub trait ToolExecutor<Invocation>: Send + Sync {false}- async fn handle(- &self,- invocation: Invocation,- ) -> Result<Box<dyn ToolOutput>, FunctionCallError>;+ fn handle(&self, invocation: Invocation) -> ToolExecutorFuture<'_>;}