From 7ca4eada90ca552eb98a2639409364e3130cf1f1 Mon Sep 17 00:00:00 2001 From: jif Date: Thu, 26 Nov 2026 14:07:08 +0000 Subject: [PATCH] Simplify tool executor lifetimes (#64159) ## Why Extension tools borrow host capabilities for each call. Expressing that borrow in the executor's type argument requires higher-ranked lifetime bounds wherever extension executors are stored or returned. ## What changed Define the per-call input as `ToolInput::Call<'a>` so `ToolExecutor` can use the same lifetime for the input, the executor borrow, and the returned future while remaining usable as a trait object. Default to borrowed `ToolCall<'a>` inputs so extension contributors can return `Arc`. Core handlers continue to take owned `ToolInvocation` inputs. GitOrigin-RevId: efbf56c1e758c59a18b192d210c2ab1b368793e2 --- .../src/mcp_tool_call/conversation_history.rs | 12 +++---- .../src/tools/code_mode/delegate_tests.rs | 5 +-- .../src/tools/code_mode/execute_handler.rs | 5 +-- .../core/src/tools/code_mode/wait_handler.rs | 5 +-- codex-rs/core/src/tools/context.rs | 4 +++ .../core/src/tools/handlers/apply_patch.rs | 5 +-- .../core/src/tools/handlers/current_time.rs | 5 +-- codex-rs/core/src/tools/handlers/dynamic.rs | 5 +-- .../src/tools/handlers/extension_tools.rs | 35 +++++-------------- .../tools/handlers/get_context_remaining.rs | 5 +-- .../list_available_plugins_to_install.rs | 5 +-- codex-rs/core/src/tools/handlers/mcp.rs | 5 +-- .../list_mcp_resource_templates.rs | 5 +-- .../mcp_resource/list_mcp_resources.rs | 5 +-- .../mcp_resource/read_mcp_resource.rs | 5 +-- .../handlers/multi_agents/close_agent.rs | 5 +-- .../handlers/multi_agents/resume_agent.rs | 5 +-- .../tools/handlers/multi_agents/send_input.rs | 5 +-- .../src/tools/handlers/multi_agents/spawn.rs | 5 +-- .../src/tools/handlers/multi_agents/wait.rs | 5 +-- .../handlers/multi_agents_v2/followup_task.rs | 5 +-- .../multi_agents_v2/interrupt_agent.rs | 5 +-- .../handlers/multi_agents_v2/list_agents.rs | 5 +-- .../handlers/multi_agents_v2/send_message.rs | 5 +-- .../tools/handlers/multi_agents_v2/spawn.rs | 5 +-- .../tools/handlers/multi_agents_v2/wait.rs | 5 +-- .../src/tools/handlers/new_context_window.rs | 5 +-- codex-rs/core/src/tools/handlers/plan.rs | 5 +-- .../src/tools/handlers/request_permissions.rs | 5 +-- .../tools/handlers/request_plugin_install.rs | 5 +-- .../src/tools/handlers/request_user_input.rs | 5 +-- .../handlers/request_user_input_async.rs | 5 +-- .../handlers/send_message_to_user_async.rs | 5 +-- codex-rs/core/src/tools/handlers/sleep.rs | 5 +-- codex-rs/core/src/tools/handlers/test_sync.rs | 5 +-- .../core/src/tools/handlers/tool_search.rs | 5 +-- .../handlers/unified_exec/exec_command.rs | 5 +-- .../handlers/unified_exec/write_stdin.rs | 5 +-- .../core/src/tools/handlers/view_image.rs | 5 +-- .../tools/handlers/wait_for_environment.rs | 5 +-- codex-rs/core/src/tools/multi_agent_tool.rs | 5 +-- codex-rs/core/src/tools/parallel.rs | 5 +-- codex-rs/core/src/tools/registry_tests.rs | 15 ++------ codex-rs/core/src/tools/router_tests.rs | 13 +++---- codex-rs/core/src/tools/spec_plan.rs | 9 ++--- .../spec_plan_strict_third_party_tests.rs | 2 +- codex-rs/core/src/tools/spec_plan_tests.rs | 21 ++++------- .../src/tools/tool_dispatch_trace_tests.rs | 5 +-- .../core/tests/suite/agents_md_refresh.rs | 3 +- codex-rs/core/tests/suite/code_mode.rs | 11 +++--- .../core/tests/suite/critical_path_runtime.rs | 9 ++--- codex-rs/core/tests/suite/search_tool.rs | 9 ++--- .../core/tests/suite/startup_cancellation.rs | 3 +- codex-rs/core/tests/suite/step_settings.rs | 9 ++--- .../ext/agent-message-board/src/extension.rs | 7 ++-- .../ext/extension-api/src/contributors.rs | 5 ++- codex-rs/ext/extension-api/tests/registry.rs | 3 +- codex-rs/ext/goal/src/extension.rs | 7 ++-- codex-rs/ext/goal/src/tool.rs | 9 ++--- .../ext/goal/tests/goal_extension_backend.rs | 13 +++---- .../src/sync_reviewer/conversation_history.rs | 5 ++- .../ext/guardian-v3/src/retrieval_tools.rs | 5 ++- .../ext/guardian-v3/src/subscription_tools.rs | 11 +++--- codex-rs/ext/history-notes/src/tools.rs | 9 ++--- .../tests/history_notes_extension.rs | 2 +- .../ext/image-generation/src/extension.rs | 3 +- codex-rs/ext/image-generation/src/tool.rs | 7 ++-- codex-rs/ext/memories/src/extension.rs | 5 ++- codex-rs/ext/memories/src/tests.rs | 5 +-- .../ext/memories/src/tools/ad_hoc_note.rs | 7 ++-- codex-rs/ext/memories/src/tools/list.rs | 7 ++-- codex-rs/ext/memories/src/tools/mod.rs | 2 +- codex-rs/ext/memories/src/tools/read.rs | 7 ++-- codex-rs/ext/memories/src/tools/search.rs | 7 ++-- .../ext/multi-env-copy-file/src/extension.rs | 3 +- codex-rs/ext/multi-env-copy-file/src/tool.rs | 7 ++-- codex-rs/ext/skills/src/extension.rs | 3 +- .../ext/skills/src/tools/installations.rs | 7 ++-- codex-rs/ext/skills/src/tools/list.rs | 7 ++-- codex-rs/ext/skills/src/tools/mod.rs | 4 +-- codex-rs/ext/skills/src/tools/read.rs | 7 ++-- .../skills_extension/merge_catalog_tests.rs | 9 ++--- codex-rs/ext/web-search/src/extension.rs | 5 ++- codex-rs/ext/web-search/src/tool.rs | 7 ++-- codex-rs/message-board-mcp/src/lib.rs | 2 +- codex-rs/message-board/src/tools.rs | 11 +++--- codex-rs/tools/src/lib.rs | 2 ++ codex-rs/tools/src/tool_executor.rs | 19 +++++++--- 88 files changed, 173 insertions(+), 401 deletions(-) diff --git a/codex-rs/core/src/mcp_tool_call/conversation_history.rs b/codex-rs/core/src/mcp_tool_call/conversation_history.rs index 68f183c18b..2e03befef2 100644 --- a/codex-rs/core/src/mcp_tool_call/conversation_history.rs +++ b/codex-rs/core/src/mcp_tool_call/conversation_history.rs @@ -39,7 +39,7 @@ use super::with_mcp_tool_call_ids_meta; pub async fn conversation_history_tools( parent: &Arc, max_output_tokens: usize, -) -> anyhow::Result ToolExecutor>>>> { +) -> anyhow::Result>> { let binding = history_binding(&parent.session).await?; let mut tools = Vec::new(); for name in ["search_messages", "read_messages"] { @@ -63,8 +63,7 @@ pub async fn conversation_history_tools( parent: Arc::downgrade(&parent.session), function, max_output_tokens, - }) - as Arc ToolExecutor>>); + }) as Arc); } Ok(tools) } @@ -93,7 +92,7 @@ struct HistoryTool { max_output_tokens: usize, } -impl<'call> ToolExecutor> for HistoryTool { +impl ToolExecutor for HistoryTool { fn tool_name(&self) -> ToolName { ToolName::namespaced("user_message", &self.function.name) } @@ -114,10 +113,7 @@ impl<'call> ToolExecutor> for HistoryTool { ToolExposure::DirectModelOnly } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let result: anyhow::Result> = async { let parent = self.parent.upgrade().context("Parent thread has stopped")?; diff --git a/codex-rs/core/src/tools/code_mode/delegate_tests.rs b/codex-rs/core/src/tools/code_mode/delegate_tests.rs index 61f0d51c9c..1da784730f 100644 --- a/codex-rs/core/src/tools/code_mode/delegate_tests.rs +++ b/codex-rs/core/src/tools/code_mode/delegate_tests.rs @@ -106,10 +106,7 @@ impl ToolExecutor for TestHandler { }) } - fn handle<'a>(&'a self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async { Ok(Box::new(FunctionToolOutput::from_text( "audit-probe-ok".to_string(), diff --git a/codex-rs/core/src/tools/code_mode/execute_handler.rs b/codex-rs/core/src/tools/code_mode/execute_handler.rs index d7357f69b2..2268812c74 100644 --- a/codex-rs/core/src/tools/code_mode/execute_handler.rs +++ b/codex-rs/core/src/tools/code_mode/execute_handler.rs @@ -179,10 +179,7 @@ impl ToolExecutor for CodeModeExecuteHandler { self.spec.clone() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 3d43e0c653..af2975ffba 100644 --- a/codex-rs/core/src/tools/code_mode/wait_handler.rs +++ b/codex-rs/core/src/tools/code_mode/wait_handler.rs @@ -59,10 +59,7 @@ impl ToolExecutor for CodeModeWaitHandler { self.spec.clone() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(self.handle_call(invocation)) } } diff --git a/codex-rs/core/src/tools/context.rs b/codex-rs/core/src/tools/context.rs index 5b274db6f9..ca69dcf9e4 100644 --- a/codex-rs/core/src/tools/context.rs +++ b/codex-rs/core/src/tools/context.rs @@ -130,6 +130,10 @@ pub struct ToolInvocation { pub(crate) environments: ToolEnvironments, } +impl codex_tools::ToolInput for ToolInvocation { + type Call<'a> = Self; +} + /// Identity of the model call that started a tool invocation, retained across code-mode waits. #[derive(Clone)] pub(crate) struct ToolCallOrigin { diff --git a/codex-rs/core/src/tools/handlers/apply_patch.rs b/codex-rs/core/src/tools/handlers/apply_patch.rs index f5a2bdb240..9d68668fc5 100644 --- a/codex-rs/core/src/tools/handlers/apply_patch.rs +++ b/codex-rs/core/src/tools/handlers/apply_patch.rs @@ -293,10 +293,7 @@ impl ToolExecutor for ApplyPatchHandler { create_apply_patch_freeform_tool(self.multi_environment) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(self.handle_call(invocation)) } } diff --git a/codex-rs/core/src/tools/handlers/current_time.rs b/codex-rs/core/src/tools/handlers/current_time.rs index f3e5cb48aa..7cf76e5677 100644 --- a/codex-rs/core/src/tools/handlers/current_time.rs +++ b/codex-rs/core/src/tools/handlers/current_time.rs @@ -87,10 +87,7 @@ impl ToolExecutor for CurrentTimeHandler { }) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { if !matches!(invocation.payload, ToolPayload::Function { .. }) { return Err(FunctionCallError::RespondToModel(format!( diff --git a/codex-rs/core/src/tools/handlers/dynamic.rs b/codex-rs/core/src/tools/handlers/dynamic.rs index 8b115a3fea..fc8b82162b 100644 --- a/codex-rs/core/src/tools/handlers/dynamic.rs +++ b/codex-rs/core/src/tools/handlers/dynamic.rs @@ -120,10 +120,7 @@ impl ToolExecutor for DynamicToolHandler { ) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index b81d2dd863..b46fcc7c83 100644 --- a/codex-rs/core/src/tools/handlers/extension_tools.rs +++ b/codex-rs/core/src/tools/handlers/extension_tools.rs @@ -27,14 +27,10 @@ use crate::tools::registry::CoreToolRuntime; use crate::tools::registry::ToolExecutor; use crate::turn_metadata::ExecutionMetadata; -pub(crate) struct ExtensionToolAdapter( - Arc codex_tools::ToolExecutor>>, -); +pub(crate) struct ExtensionToolAdapter(Arc); impl ExtensionToolAdapter { - pub(crate) fn new( - executor: Arc codex_tools::ToolExecutor>>, - ) -> Self { + pub(crate) fn new(executor: Arc) -> Self { Self(executor) } } @@ -60,10 +56,7 @@ impl ToolExecutor for ExtensionToolAdapter { self.0.search_info() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let step = &invocation.step_context; let selected: Vec<_> = match &invocation.environments { @@ -296,9 +289,7 @@ mod tests { struct StubExtensionExecutor; - impl<'call> codex_extension_api::ToolExecutor> - for StubExtensionExecutor - { + impl codex_extension_api::ToolExecutor for StubExtensionExecutor { fn tool_name(&self) -> codex_tools::ToolName { codex_tools::ToolName::plain("extension_echo") } @@ -324,11 +315,8 @@ mod tests { fn handle<'a>( &'a self, - _call: codex_tools::ToolCall<'call>, - ) -> codex_tools::ToolExecutorFuture<'a> - where - 'call: 'a, - { + _call: codex_tools::ToolCall<'a>, + ) -> codex_tools::ToolExecutorFuture<'a> { Box::pin(async { Ok( Box::new(codex_tools::JsonToolOutput::new(json!({ "ok": true }))) @@ -343,9 +331,7 @@ mod tests { captured_sandbox_cwds: Arc>>, } - impl<'call> codex_extension_api::ToolExecutor> - for CapturingExtensionExecutor - { + impl codex_extension_api::ToolExecutor for CapturingExtensionExecutor { fn tool_name(&self) -> codex_tools::ToolName { codex_tools::ToolName::plain("extension_echo") } @@ -363,11 +349,8 @@ mod tests { fn handle<'a>( &'a self, - call: codex_tools::ToolCall<'call>, - ) -> codex_tools::ToolExecutorFuture<'a> - where - 'call: 'a, - { + call: codex_tools::ToolCall<'a>, + ) -> codex_tools::ToolExecutorFuture<'a> { Box::pin(self.handle_call(call)) } } diff --git a/codex-rs/core/src/tools/handlers/get_context_remaining.rs b/codex-rs/core/src/tools/handlers/get_context_remaining.rs index 50dccafa9e..3483c1b177 100644 --- a/codex-rs/core/src/tools/handlers/get_context_remaining.rs +++ b/codex-rs/core/src/tools/handlers/get_context_remaining.rs @@ -82,10 +82,7 @@ impl ToolExecutor for GetContextRemainingHandler { self.spec.clone() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { if !matches!(invocation.payload, ToolPayload::Function { .. }) { return Err(FunctionCallError::RespondToModel( 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.rs index 0860df56bf..2a6d5bbe0a 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 @@ -67,10 +67,7 @@ impl ToolExecutor for ListAvailablePluginsToInstallHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 2b351723e4..5041f94788 100644 --- a/codex-rs/core/src/tools/handlers/mcp.rs +++ b/codex-rs/core/src/tools/handlers/mcp.rs @@ -235,10 +235,7 @@ impl ToolExecutor for McpHandler { ) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 1ebdde81ab..89f8cde5e4 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 @@ -34,10 +34,7 @@ impl ToolExecutor for ListMcpResourceTemplatesHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 7b57a57140..9003c3f335 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 @@ -34,10 +34,7 @@ impl ToolExecutor for ListMcpResourcesHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index cae7d4d8f4..95c3626a52 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 @@ -36,10 +36,7 @@ impl ToolExecutor for ReadMcpResourceHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 5a227aba68..fbd6f954bf 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 @@ -21,10 +21,7 @@ impl ToolExecutor for Handler { ) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index c00c94b216..80a012a6a5 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 @@ -22,10 +22,7 @@ impl ToolExecutor for Handler { ) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index caa427f12d..7291b8a918 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 @@ -25,10 +25,7 @@ impl ToolExecutor for Handler { ) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 70168d7a0d..d30593a0ef 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents/spawn.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents/spawn.rs @@ -45,10 +45,7 @@ impl ToolExecutor for Handler { ) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 0a9dab0b37..7aba2c68c8 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents/wait.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents/wait.rs @@ -44,10 +44,7 @@ impl ToolExecutor for Handler { ) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index fa129704a0..5761e54674 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 @@ -17,10 +17,7 @@ impl ToolExecutor for Handler { create_followup_task_tool() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let mut analytics = ToolCallAnalytics::new(&invocation, CollabAgentTool::FollowupTask); let result = self.handle_call(invocation, &mut analytics).await; 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.rs index a9b06bcf7b..53e1523fa5 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 @@ -17,10 +17,7 @@ impl ToolExecutor for Handler { create_interrupt_agent_tool_v2() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let mut analytics = ToolCallAnalytics::new(&invocation, CollabAgentTool::InterruptAgent); 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.rs index c207553c25..477768aa4f 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 @@ -18,10 +18,7 @@ impl ToolExecutor for Handler { create_list_agents_tool() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let analytics = ToolCallAnalytics::new(&invocation, CollabAgentTool::ListAgents); let result = self.handle_call(invocation).await; 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.rs index 7713f01103..f916cb40fa 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 @@ -17,10 +17,7 @@ impl ToolExecutor for Handler { create_send_message_tool() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let mut analytics = ToolCallAnalytics::new(&invocation, CollabAgentTool::SendMessage); let result = self.handle_call(invocation, &mut analytics).await; 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.rs index b43b4f7eae..9bdfecfe7f 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 @@ -41,10 +41,7 @@ impl ToolExecutor for Handler { create_spawn_agent_tool_v2(self.options.clone(), self.description_override.as_deref()) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let analytics = invocation.session.services.analytics_events_client.clone(); let sender_thread_id = invocation.session.thread_id; 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.rs index a8a5a04b30..4fdbeb342d 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 @@ -29,10 +29,7 @@ impl ToolExecutor for Handler { create_wait_agent_tool_v2(self.options) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(self.handle_call(invocation)) } } diff --git a/codex-rs/core/src/tools/handlers/new_context_window.rs b/codex-rs/core/src/tools/handlers/new_context_window.rs index 227aad0b58..268b41ba19 100644 --- a/codex-rs/core/src/tools/handlers/new_context_window.rs +++ b/codex-rs/core/src/tools/handlers/new_context_window.rs @@ -35,10 +35,7 @@ impl ToolExecutor for NewContextWindowHandler { self.spec.clone() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { if !matches!(invocation.payload, ToolPayload::Function { .. }) { return Err(FunctionCallError::RespondToModel( diff --git a/codex-rs/core/src/tools/handlers/plan.rs b/codex-rs/core/src/tools/handlers/plan.rs index 2918c5e3f6..92db3e72d0 100644 --- a/codex-rs/core/src/tools/handlers/plan.rs +++ b/codex-rs/core/src/tools/handlers/plan.rs @@ -55,10 +55,7 @@ impl ToolExecutor for PlanHandler { create_update_plan_tool() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 15012f4d6b..253a524f7d 100644 --- a/codex-rs/core/src/tools/handlers/request_permissions.rs +++ b/codex-rs/core/src/tools/handlers/request_permissions.rs @@ -94,10 +94,7 @@ impl ToolExecutor for RequestPermissionsHandler { create_request_permissions_tool(request_permissions_tool_description()) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 043ce5482c..0e422bc5f5 100644 --- a/codex-rs/core/src/tools/handlers/request_plugin_install.rs +++ b/codex-rs/core/src/tools/handlers/request_plugin_install.rs @@ -81,10 +81,7 @@ impl ToolExecutor for RequestPluginInstallHandler { false } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 1f3c244d52..575da74c01 100644 --- a/codex-rs/core/src/tools/handlers/request_user_input.rs +++ b/codex-rs/core/src/tools/handlers/request_user_input.rs @@ -31,10 +31,7 @@ impl ToolExecutor for RequestUserInputHandler { create_request_user_input_tool(request_user_input_tool_description(&self.available_modes)) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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_async.rs b/codex-rs/core/src/tools/handlers/request_user_input_async.rs index 19a6093619..867d0267be 100644 --- a/codex-rs/core/src/tools/handlers/request_user_input_async.rs +++ b/codex-rs/core/src/tools/handlers/request_user_input_async.rs @@ -86,10 +86,7 @@ impl ToolExecutor for RequestUserInputAsyncHandler { }) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let ToolInvocation { session, diff --git a/codex-rs/core/src/tools/handlers/send_message_to_user_async.rs b/codex-rs/core/src/tools/handlers/send_message_to_user_async.rs index e0239ca477..779e11bd1a 100644 --- a/codex-rs/core/src/tools/handlers/send_message_to_user_async.rs +++ b/codex-rs/core/src/tools/handlers/send_message_to_user_async.rs @@ -56,10 +56,7 @@ impl ToolExecutor for SendMessageToUserAsyncHandler { }) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let ToolInvocation { session, diff --git a/codex-rs/core/src/tools/handlers/sleep.rs b/codex-rs/core/src/tools/handlers/sleep.rs index a25388811a..7d8db7da88 100644 --- a/codex-rs/core/src/tools/handlers/sleep.rs +++ b/codex-rs/core/src/tools/handlers/sleep.rs @@ -75,10 +75,7 @@ impl ToolExecutor for SleepHandler { ToolExposure::DirectModelOnly } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let ToolInvocation { session, diff --git a/codex-rs/core/src/tools/handlers/test_sync.rs b/codex-rs/core/src/tools/handlers/test_sync.rs index f9f15f01ad..e4b4a9e1ac 100644 --- a/codex-rs/core/src/tools/handlers/test_sync.rs +++ b/codex-rs/core/src/tools/handlers/test_sync.rs @@ -73,10 +73,7 @@ impl ToolExecutor for TestSyncHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 0af3b2f4bf..4f1b85e057 100644 --- a/codex-rs/core/src/tools/handlers/tool_search.rs +++ b/codex-rs/core/src/tools/handlers/tool_search.rs @@ -212,10 +212,7 @@ impl ToolExecutor for ToolSearchHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index 313074f399..668e78ee60 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 @@ -120,10 +120,7 @@ impl ToolExecutor for ExecCommandHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index b0eed3b67a..22db0569dc 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 @@ -57,10 +57,7 @@ impl ToolExecutor for WriteStdinHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + 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.rs index ede3e09c29..b4206e48c1 100644 --- a/codex-rs/core/src/tools/handlers/view_image.rs +++ b/codex-rs/core/src/tools/handlers/view_image.rs @@ -88,10 +88,7 @@ impl ToolExecutor for ViewImageHandler { true } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(self.handle_call(invocation)) } } diff --git a/codex-rs/core/src/tools/handlers/wait_for_environment.rs b/codex-rs/core/src/tools/handlers/wait_for_environment.rs index 2df554352e..7777e0d605 100644 --- a/codex-rs/core/src/tools/handlers/wait_for_environment.rs +++ b/codex-rs/core/src/tools/handlers/wait_for_environment.rs @@ -105,10 +105,7 @@ impl ToolExecutor for WaitForEnvironmentHandler { }) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async move { let ToolInvocation { payload, diff --git a/codex-rs/core/src/tools/multi_agent_tool.rs b/codex-rs/core/src/tools/multi_agent_tool.rs index 513df85797..8048dabdb1 100644 --- a/codex-rs/core/src/tools/multi_agent_tool.rs +++ b/codex-rs/core/src/tools/multi_agent_tool.rs @@ -125,10 +125,7 @@ impl ToolExecutor for MultiAgentV2ToolOverrides { self.handler.search_info() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { self.handler.handle(invocation) } } diff --git a/codex-rs/core/src/tools/parallel.rs b/codex-rs/core/src/tools/parallel.rs index 79e4b3d455..8e13799c02 100644 --- a/codex-rs/core/src/tools/parallel.rs +++ b/codex-rs/core/src/tools/parallel.rs @@ -1010,10 +1010,7 @@ mod tests { }) } - fn handle<'a>(&'a self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { self.calls.fetch_add(1, Ordering::Relaxed); Box::pin(async { Ok( diff --git a/codex-rs/core/src/tools/registry_tests.rs b/codex-rs/core/src/tools/registry_tests.rs index da6e66b209..2459ae1ca3 100644 --- a/codex-rs/core/src/tools/registry_tests.rs +++ b/codex-rs/core/src/tools/registry_tests.rs @@ -22,10 +22,7 @@ impl ToolExecutor for TestHandler { test_spec(&self.tool_name) } - fn handle<'a>(&'a self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async { Ok( Box::new(crate::tools::context::FunctionToolOutput::from_text( @@ -53,10 +50,7 @@ impl ToolExecutor for ReadinessTestHandler { self.handler.spec() } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { self.handler.handle(invocation) } } @@ -89,10 +83,7 @@ impl ToolExecutor for LifecycleTestHandler { test_spec(&self.tool_name) } - fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { assert_eq!( invocation.tool_name, self.tool_name.clone().with_default_namespace() diff --git a/codex-rs/core/src/tools/router_tests.rs b/codex-rs/core/src/tools/router_tests.rs index 82c89d2aaf..e2f5a3e963 100644 --- a/codex-rs/core/src/tools/router_tests.rs +++ b/codex-rs/core/src/tools/router_tests.rs @@ -116,14 +116,14 @@ impl codex_extension_api::ToolContributor for ExtensionEchoContributor { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { vec![Arc::new(ExtensionEchoExecutor)] } } struct ExtensionEchoExecutor; -impl<'call> ToolExecutor> for ExtensionEchoExecutor { +impl ToolExecutor for ExtensionEchoExecutor { fn tool_name(&self) -> ToolName { ToolName::namespaced("extension/", "echo") } @@ -151,10 +151,7 @@ impl<'call> ToolExecutor> for ExtensionEchoExecutor { }) } - fn handle<'a>(&'a self, call: ExtensionToolCall<'call>) -> codex_tools::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ExtensionToolCall<'a>) -> codex_tools::ToolExecutorFuture<'a> { Box::pin(self.handle_call(call)) } } @@ -184,9 +181,7 @@ fn extension_tool_test_registry() -> Arc> { fn test_tool_router( step_context: &StepContext, mcp_tools: Vec, - extension_tool_executors: impl IntoIterator< - Item = Arc ToolExecutor>>, - >, + extension_tool_executors: impl IntoIterator>, dynamic_tools: &[DynamicToolSpec], ) -> ToolRouter { let mut registry = build_core_tool_registry( diff --git a/codex-rs/core/src/tools/spec_plan.rs b/codex-rs/core/src/tools/spec_plan.rs index 1e9f07e781..ff3214c55d 100644 --- a/codex-rs/core/src/tools/spec_plan.rs +++ b/codex-rs/core/src/tools/spec_plan.rs @@ -84,7 +84,6 @@ use codex_protocol::protocol::MultiAgentVersion; use codex_tools::IndirectNamespacePrefixes; use codex_tools::ResponsesApiNamespaceTool; use codex_tools::TOOL_SEARCH_TOOL_NAME; -use codex_tools::ToolCall as ExtensionToolCall; use codex_tools::ToolEnvironmentMode; use codex_tools::ToolExecutor; use codex_tools::ToolExposures; @@ -326,9 +325,7 @@ pub(crate) fn append_source_tools( model_info: &ModelInfo, registry: &mut ToolRegistry, mcp_tools: Vec, - extension_tool_executors: impl IntoIterator< - Item = Arc ToolExecutor>>, - >, + extension_tool_executors: impl IntoIterator>, dynamic_tools: &[DynamicToolSpec], ) -> Vec { for tool in mcp_tools { @@ -352,7 +349,7 @@ pub(crate) fn append_source_tools( pub(crate) fn extension_tool_executors<'a>( session: &'a Session, step_store: &'a ExtensionData, -) -> impl Iterator ToolExecutor>>> + 'a { +) -> impl Iterator> + 'a { session .services .extensions @@ -1629,7 +1626,7 @@ fn append_tool_search_executor( fn append_extension_tool_executors( turn_context: &TurnContext, model_info: &ModelInfo, - executors: impl IntoIterator ToolExecutor>>>, + executors: impl IntoIterator>, registry: &mut ToolRegistry, ) -> Option { let standalone_web_search_enabled = standalone_web_search_enabled(turn_context, model_info); diff --git a/codex-rs/core/src/tools/spec_plan_strict_third_party_tests.rs b/codex-rs/core/src/tools/spec_plan_strict_third_party_tests.rs index 4b3b66f2bc..466c3fe358 100644 --- a/codex-rs/core/src/tools/spec_plan_strict_third_party_tests.rs +++ b/codex-rs/core/src/tools/spec_plan_strict_third_party_tests.rs @@ -205,7 +205,7 @@ async fn strict_finalization_cannot_resurrect_hidden_or_policy_denied_tools() { ), mcp_runtime("denied", "mcp__denied", "lookup", ToolExposure::Direct), ], - std::iter::empty:: ToolExecutor>>>(), + std::iter::empty::>(), &[ dynamic_tool( /*namespace*/ None, diff --git a/codex-rs/core/src/tools/spec_plan_tests.rs b/codex-rs/core/src/tools/spec_plan_tests.rs index a6fff2fad8..3900fd23a6 100644 --- a/codex-rs/core/src/tools/spec_plan_tests.rs +++ b/codex-rs/core/src/tools/spec_plan_tests.rs @@ -69,7 +69,7 @@ const MULTI_AGENT_V2_NAMESPACE: &str = "collaboration"; struct ToolPlanInputs { tool_runtimes: Vec, tool_suggest_candidates: Option, - extension_tool_executors: Vec ToolExecutor>>>, + extension_tool_executors: Vec>, wait_for_environment_tool_config: Option>, dynamic_tools: Vec, } @@ -317,7 +317,7 @@ struct TestNamespaceExtensionTool { tool_name: &'static str, } -impl<'call> ToolExecutor> for TestNamespaceExtensionTool { +impl ToolExecutor for TestNamespaceExtensionTool { fn tool_name(&self) -> ToolName { ToolName::namespaced(self.namespace, self.tool_name) } @@ -337,10 +337,7 @@ impl<'call> ToolExecutor> for TestNamespaceExtensionToo }) } - fn handle<'a>(&'a self, _call: ExtensionToolCall<'call>) -> codex_tools::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, _call: ExtensionToolCall<'a>) -> codex_tools::ToolExecutorFuture<'a> { Box::pin(async { Ok(Box::new(codex_tools::JsonToolOutput::new(json!({}))) as Box) }) @@ -349,7 +346,7 @@ impl<'call> ToolExecutor> for TestNamespaceExtensionToo struct DeferredExtensionTool; -impl<'call> ToolExecutor> for DeferredExtensionTool { +impl ToolExecutor for DeferredExtensionTool { fn tool_name(&self) -> ToolName { ToolName::plain("extension_echo") } @@ -376,10 +373,7 @@ impl<'call> ToolExecutor> for DeferredExtensionTool { ToolExposure::Deferred } - fn handle<'a>(&'a self, _call: ExtensionToolCall<'call>) -> codex_tools::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, _call: ExtensionToolCall<'a>) -> codex_tools::ToolExecutorFuture<'a> { Box::pin(async { panic!("spec planning should not execute extension tools") }) } } @@ -536,10 +530,7 @@ async fn allowed_tools_filter_sources_before_code_mode_and_discovery() { mcp_runtime("kept", "kept", "lookup", ToolExposure::Deferred), mcp_runtime("excluded", "excluded", "lookup", ToolExposure::Deferred), ], - [Arc::new(DeferredExtensionTool) - as Arc< - dyn for<'call> ToolExecutor>, - >], + [Arc::new(DeferredExtensionTool) as Arc], &[dynamic_tool( /*namespace*/ None, "dynamic_echo", diff --git a/codex-rs/core/src/tools/tool_dispatch_trace_tests.rs b/codex-rs/core/src/tools/tool_dispatch_trace_tests.rs index 12f8098999..690d966c8c 100644 --- a/codex-rs/core/src/tools/tool_dispatch_trace_tests.rs +++ b/codex-rs/core/src/tools/tool_dispatch_trace_tests.rs @@ -48,10 +48,7 @@ impl ToolExecutor for TestHandler { }) } - fn handle<'a>(&'a self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a> - where - ToolInvocation: 'a, - { + fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> { Box::pin(async { Ok( Box::new(FunctionToolOutput::from_text("ok".to_string(), Some(true))) diff --git a/codex-rs/core/tests/suite/agents_md_refresh.rs b/codex-rs/core/tests/suite/agents_md_refresh.rs index 7aeb922602..79a906edf2 100644 --- a/codex-rs/core/tests/suite/agents_md_refresh.rs +++ b/codex-rs/core/tests/suite/agents_md_refresh.rs @@ -8,7 +8,6 @@ use codex_protocol::dynamic_tools::DynamicToolFunctionSpec; use codex_protocol::dynamic_tools::DynamicToolSpec; use codex_protocol::request_user_input::RequestUserInputAnswer; use codex_protocol::request_user_input::RequestUserInputResponse; -use codex_tools::ToolCall; use codex_tools::ToolExecutor; use pretty_assertions::assert_eq; use std::collections::HashMap; @@ -42,7 +41,7 @@ impl ToolContributor for StepPreparationObserver { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { if let Some(ready) = self.tools_ready.lock().expect("tool gate").take() { ready .send(()) diff --git a/codex-rs/core/tests/suite/code_mode.rs b/codex-rs/core/tests/suite/code_mode.rs index 7f1bbb0547..9c91625ea5 100644 --- a/codex-rs/core/tests/suite/code_mode.rs +++ b/codex-rs/core/tests/suite/code_mode.rs @@ -8185,7 +8185,7 @@ impl ToolContributor for NamespacedCustomTool { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { Vec::new() } @@ -8194,7 +8194,7 @@ impl ToolContributor for NamespacedCustomTool { _session_store: &ExtensionData, _thread_store: &ExtensionData, _step_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { vec![Arc::new(Self { generation: self.generations.fetch_add(1, Ordering::Relaxed) + 1, generations: Arc::clone(&self.generations), @@ -8202,7 +8202,7 @@ impl ToolContributor for NamespacedCustomTool { } } -impl<'call> ToolExecutor> for NamespacedCustomTool { +impl ToolExecutor for NamespacedCustomTool { fn tool_name(&self) -> ToolName { ToolName::namespaced("editor", "apply_patch") } @@ -8224,10 +8224,7 @@ impl<'call> ToolExecutor> for NamespacedCustomTool { }) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let ToolPayload::Custom { input } = call.payload else { return Err(FunctionCallError::Fatal( diff --git a/codex-rs/core/tests/suite/critical_path_runtime.rs b/codex-rs/core/tests/suite/critical_path_runtime.rs index f286d292f3..b69b0ffa52 100644 --- a/codex-rs/core/tests/suite/critical_path_runtime.rs +++ b/codex-rs/core/tests/suite/critical_path_runtime.rs @@ -63,12 +63,12 @@ impl ToolContributor for GatedTool { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { vec![Arc::new(self.clone())] } } -impl<'call> ToolExecutor> for GatedTool { +impl ToolExecutor for GatedTool { fn tool_name(&self) -> ToolName { ToolName::plain(if matches!(self.admission, Admission::Unsupported) { "followup_task" @@ -92,10 +92,7 @@ impl<'call> ToolExecutor> for GatedTool { matches!(self.admission, Admission::Parallel) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { self.entered .send((call.call_id.to_string(), Instant::now())) diff --git a/codex-rs/core/tests/suite/search_tool.rs b/codex-rs/core/tests/suite/search_tool.rs index 280fa33ee2..d28749af2d 100644 --- a/codex-rs/core/tests/suite/search_tool.rs +++ b/codex-rs/core/tests/suite/search_tool.rs @@ -953,12 +953,12 @@ impl ToolContributor for DeferredCustomTool { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { vec![Arc::new(Self)] } } -impl<'call> ToolExecutor> for DeferredCustomTool { +impl ToolExecutor for DeferredCustomTool { fn tool_name(&self) -> ToolName { ToolName::plain("custom_echo") } @@ -980,10 +980,7 @@ impl<'call> ToolExecutor> for DeferredCustomTool { ToolExposure::Deferred } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let ToolPayload::Custom { input } = call.payload else { return Err(FunctionCallError::Fatal( diff --git a/codex-rs/core/tests/suite/startup_cancellation.rs b/codex-rs/core/tests/suite/startup_cancellation.rs index 5c9e2b5dc9..364860c9fc 100644 --- a/codex-rs/core/tests/suite/startup_cancellation.rs +++ b/codex-rs/core/tests/suite/startup_cancellation.rs @@ -187,7 +187,6 @@ async fn step_preparation_finishes_before_tools_and_world_state() -> Result<()> use codex_extension_api::ExtensionFuture; use codex_extension_api::SelectedPluginSnapshot; use codex_extension_api::StepPreparationInput; - use codex_extension_api::ToolCall; use codex_extension_api::ToolContributor; use codex_extension_api::ToolExecutor; use codex_extension_api::WorldStateContributionInput; @@ -221,7 +220,7 @@ async fn step_preparation_finishes_before_tools_and_world_state() -> Result<()> _session_store: &ExtensionData, _thread_store: &ExtensionData, step_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { assert!(step_store.get::().is_some()); assert_eq!( *step_store diff --git a/codex-rs/core/tests/suite/step_settings.rs b/codex-rs/core/tests/suite/step_settings.rs index 409d973c78..96fa318dc2 100644 --- a/codex-rs/core/tests/suite/step_settings.rs +++ b/codex-rs/core/tests/suite/step_settings.rs @@ -2998,12 +2998,12 @@ impl ToolContributor for SettingsEcho { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { vec![Arc::new(self.clone())] } } -impl<'call> ToolExecutor> for SettingsEcho { +impl ToolExecutor for SettingsEcho { fn tool_name(&self) -> ToolName { ToolName::plain("extension_settings") } @@ -3019,10 +3019,7 @@ impl<'call> ToolExecutor> for SettingsEcho { }) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { *self.history.lock().expect("history lock") = Some(call.conversation_history); let metadata: Value = serde_json::from_str( diff --git a/codex-rs/ext/agent-message-board/src/extension.rs b/codex-rs/ext/agent-message-board/src/extension.rs index 3b2a40ee64..ccfe85e498 100644 --- a/codex-rs/ext/agent-message-board/src/extension.rs +++ b/codex-rs/ext/agent-message-board/src/extension.rs @@ -22,7 +22,6 @@ use codex_protocol::ThreadId; use codex_protocol::error::CodexErr; use codex_protocol::error::Result; use codex_protocol::openai_models::MultiAgentToolMessages; -use codex_tools::ToolCall; use codex_tools::ToolExecutor; use futures::future::BoxFuture; use std::sync::Arc; @@ -102,7 +101,7 @@ impl ToolContributor for BoardExtension { &self, _session_store: &ExtensionData, thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { self.tools_with_descriptions(thread_store, /*tool_messages*/ None) } @@ -111,7 +110,7 @@ impl ToolContributor for BoardExtension { _session_store: &ExtensionData, thread_store: &ExtensionData, step_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { let tool_messages = step_store.get::(); self.tools_with_descriptions(thread_store, tool_messages.as_deref()) } @@ -122,7 +121,7 @@ impl BoardExtension { &self, thread_store: &ExtensionData, tool_messages: Option<&MultiAgentToolMessages>, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { thread_store .get::() .map_or_else(Vec::new, |binding| { diff --git a/codex-rs/ext/extension-api/src/contributors.rs b/codex-rs/ext/extension-api/src/contributors.rs index 89f3ca971f..371e65eaec 100644 --- a/codex-rs/ext/extension-api/src/contributors.rs +++ b/codex-rs/ext/extension-api/src/contributors.rs @@ -10,7 +10,6 @@ use codex_exec_server_protocol::ExecutorCapabilityDiscoveryV2Snapshot; use codex_protocol::capabilities::SelectedCapabilityRoot; use codex_protocol::items::TurnItem; use codex_protocol::protocol::TokenUsageInfo; -use codex_tools::ToolCall; use codex_tools::ToolExecutor; use crate::ExtensionData; @@ -429,7 +428,7 @@ pub trait ToolContributor: Send + Sync { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { Vec::new() } @@ -439,7 +438,7 @@ pub trait ToolContributor: Send + Sync { session_store: &ExtensionData, thread_store: &ExtensionData, _step_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { self.tools(session_store, thread_store) } } diff --git a/codex-rs/ext/extension-api/tests/registry.rs b/codex-rs/ext/extension-api/tests/registry.rs index 978635f965..19e1721b46 100644 --- a/codex-rs/ext/extension-api/tests/registry.rs +++ b/codex-rs/ext/extension-api/tests/registry.rs @@ -22,7 +22,6 @@ use codex_extension_api::ResponseItem; use codex_extension_api::SkillInvocationContributor; use codex_extension_api::ThreadLifecycleContributor; use codex_extension_api::TokenUsageContributor; -use codex_extension_api::ToolCall; use codex_extension_api::ToolContributor; use codex_extension_api::ToolExecutor; use codex_extension_api::ToolLifecycleContributor; @@ -179,7 +178,7 @@ impl ToolContributor for AllContributors { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { Vec::new() } } diff --git a/codex-rs/ext/goal/src/extension.rs b/codex-rs/ext/goal/src/extension.rs index c2a23512c3..5850fb42c5 100644 --- a/codex-rs/ext/goal/src/extension.rs +++ b/codex-rs/ext/goal/src/extension.rs @@ -15,7 +15,6 @@ use codex_extension_api::ThreadResumeInput; use codex_extension_api::ThreadStartInput; use codex_extension_api::ThreadStopInput; use codex_extension_api::TokenUsageContributor; -use codex_extension_api::ToolCall; use codex_extension_api::ToolCallOutcome; use codex_extension_api::ToolContributor; use codex_extension_api::ToolExecutor; @@ -560,9 +559,7 @@ where &self, _session_store: &ExtensionData, thread_store: &ExtensionData, - ) -> Vec< - Arc codex_extension_api::ToolExecutor>>, - > { + ) -> Vec> { let Some(runtime) = goal_runtime_handle(thread_store) else { return Vec::new(); }; @@ -603,7 +600,7 @@ where .into_iter() .map(|mut tool| { tool.execution_allowed = runtime.tools_available(); - Arc::new(tool) as Arc ToolExecutor>> + Arc::new(tool) as Arc }) .collect() } diff --git a/codex-rs/ext/goal/src/tool.rs b/codex-rs/ext/goal/src/tool.rs index cc11e8488a..829ef34b08 100644 --- a/codex-rs/ext/goal/src/tool.rs +++ b/codex-rs/ext/goal/src/tool.rs @@ -142,7 +142,7 @@ impl GoalToolExecutor { } } -impl<'call> ToolExecutor> for GoalToolExecutor { +impl ToolExecutor for GoalToolExecutor { fn tool_name(&self) -> ToolName { ToolName::plain(match self.kind { GoalToolKind::Get => GET_GOAL_TOOL_NAME, @@ -165,11 +165,8 @@ impl<'call> ToolExecutor> for GoalToolExecutor { fn handle<'a>( &'a self, - invocation: ToolCall<'call>, - ) -> codex_extension_api::ToolExecutorFuture<'a> - where - 'call: 'a, - { + invocation: ToolCall<'a>, + ) -> codex_extension_api::ToolExecutorFuture<'a> { Box::pin(async move { if !self.execution_allowed { return Err(FunctionCallError::RespondToModel( diff --git a/codex-rs/ext/goal/tests/goal_extension_backend.rs b/codex-rs/ext/goal/tests/goal_extension_backend.rs index cdcacc3c2f..c9aef31512 100644 --- a/codex-rs/ext/goal/tests/goal_extension_backend.rs +++ b/codex-rs/ext/goal/tests/goal_extension_backend.rs @@ -1637,7 +1637,7 @@ async fn goal_service_enforces_maximum_token_budget_on_creation_and_updates() -> async fn installed_tools( runtime: Arc, thread_id: ThreadId, -) -> Vec ToolExecutor>>> { +) -> Vec> { installed_tools_with_start( runtime, thread_id, @@ -1652,7 +1652,7 @@ async fn installed_tools_with_start( thread_id: ThreadId, session_source: SessionSource, persistent_thread_state_available: bool, -) -> Vec ToolExecutor>>> { +) -> Vec> { let mut builder = ExtensionRegistryBuilder::<()>::new(); let goal_service = Arc::new(GoalService::new()); install_with_backend( @@ -1692,7 +1692,7 @@ async fn installed_tools_with_start( .collect() } -fn tool_names(tools: &[Arc ToolExecutor>>]) -> Vec { +fn tool_names(tools: &[Arc]) -> Vec { tools.iter().map(|tool| tool.tool_name().name).collect() } @@ -1794,7 +1794,7 @@ impl GoalExtensionHarness { }) } - fn tools(&self) -> Vec ToolExecutor>>> { + fn tools(&self) -> Vec> { self.registry .tool_contributors() .iter() @@ -1948,10 +1948,7 @@ impl GoalExtensionHarness { } } -fn tool_by_name<'a>( - tools: &'a [Arc ToolExecutor>>], - name: &str, -) -> &'a Arc ToolExecutor>> { +fn tool_by_name<'a>(tools: &'a [Arc], name: &str) -> &'a Arc { tools .iter() .find(|tool| tool.tool_name().namespace.is_none() && tool.tool_name().name == name) diff --git a/codex-rs/ext/guardian-v2/src/sync_reviewer/conversation_history.rs b/codex-rs/ext/guardian-v2/src/sync_reviewer/conversation_history.rs index 0fc6c4cd55..fa213d8404 100644 --- a/codex-rs/ext/guardian-v2/src/sync_reviewer/conversation_history.rs +++ b/codex-rs/ext/guardian-v2/src/sync_reviewer/conversation_history.rs @@ -8,7 +8,6 @@ use std::sync::Weak; use codex_core::CodexThread; use codex_extension_api::ExtensionData; use codex_extension_api::ExtensionFuture; -use codex_extension_api::ToolCall; use codex_extension_api::ToolContributor; use codex_extension_api::ToolExecutor; use codex_extension_api::TurnLifecycleContributor; @@ -19,7 +18,7 @@ pub(super) struct ConversationHistoryTools { pub parent: Weak, } -struct HistoryTools(Vec ToolExecutor>>>); +struct HistoryTools(Vec>); impl TurnLifecycleContributor for ConversationHistoryTools { fn turn_start_phase(&self, _thread_store: &ExtensionData) -> TurnStartPhase { @@ -54,7 +53,7 @@ impl ToolContributor for ConversationHistoryTools { &self, _session_store: &ExtensionData, thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { thread_store .get::() .map(|tools| tools.0.clone()) diff --git a/codex-rs/ext/guardian-v3/src/retrieval_tools.rs b/codex-rs/ext/guardian-v3/src/retrieval_tools.rs index 44bd6454ff..329bc4f226 100644 --- a/codex-rs/ext/guardian-v3/src/retrieval_tools.rs +++ b/codex-rs/ext/guardian-v3/src/retrieval_tools.rs @@ -11,7 +11,6 @@ use codex_message_board::MessageBoardTool; use codex_message_board::message_board_tools; use codex_protocol::AgentPath; use codex_protocol::ThreadId; -use codex_tools::ToolCall; use codex_tools::ToolExecutor; use codex_tools::ToolName; use std::sync::Arc; @@ -69,7 +68,7 @@ impl LiveRetrievalBinding { .map(|name| ToolName::namespaced(NAMESPACE, name)) } - pub fn tools(&self) -> Vec ToolExecutor>>> { + pub fn tools(&self) -> Vec> { let mut tools = message_board_tools( &LIVE_READ_TOOLS, self.board.clone(), @@ -94,7 +93,7 @@ impl ToolContributor for RetrievalTools { &self, _session: &ExtensionData, thread: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { thread .get::() .map_or_else(Vec::new, |binding| binding.tools()) diff --git a/codex-rs/ext/guardian-v3/src/subscription_tools.rs b/codex-rs/ext/guardian-v3/src/subscription_tools.rs index e75eda88a8..7c5ff7a6b3 100644 --- a/codex-rs/ext/guardian-v3/src/subscription_tools.rs +++ b/codex-rs/ext/guardian-v3/src/subscription_tools.rs @@ -77,7 +77,7 @@ pub(super) fn tools( path: &AgentPath, namespace: &str, namespace_description: &str, -) -> impl Iterator ToolExecutor>>> { +) -> impl Iterator> { TOOLS .into_iter() .map(move |(name, description, operation)| { @@ -111,11 +111,11 @@ pub(super) fn tools( operation, name, spec, - }) as Arc ToolExecutor>> + }) as Arc }) } -impl<'call> ToolExecutor> for SubscriptionTool { +impl ToolExecutor for SubscriptionTool { fn tool_name(&self) -> ToolName { self.name.clone() } @@ -128,10 +128,7 @@ impl<'call> ToolExecutor> for SubscriptionTool { matches!(self.operation, Operation::List) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let raw = call.function_arguments()?; if raw.len() > MAX_TOOL_ARGUMENT_KIB * 1024 { diff --git a/codex-rs/ext/history-notes/src/tools.rs b/codex-rs/ext/history-notes/src/tools.rs index fa4efbedb6..4d993502b8 100644 --- a/codex-rs/ext/history-notes/src/tools.rs +++ b/codex-rs/ext/history-notes/src/tools.rs @@ -49,7 +49,7 @@ use serde_json::json; use std::marker::PhantomData; use std::sync::Arc; -pub(crate) type Executor = Arc ToolExecutor>>; +pub(crate) type Executor = Arc; // Keep the catalog key, tool name, request type and HTTP route in one registration. macro_rules! register_tools { @@ -154,7 +154,7 @@ struct HistoryNotesTool { spec: ToolSpec, } -impl<'call, R: Request, B: Handle> ToolExecutor> for HistoryNotesTool { +impl> ToolExecutor for HistoryNotesTool { fn tool_name(&self) -> ToolName { ToolName::namespaced(R::NAMESPACE.name, R::NAME) } @@ -171,10 +171,7 @@ impl<'call, R: Request, B: Handle> ToolExecutor> for HistoryN R::PARALLEL } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let input = parse_arguments(call.function_arguments()?)?; let response = self diff --git a/codex-rs/ext/history-notes/tests/history_notes_extension.rs b/codex-rs/ext/history-notes/tests/history_notes_extension.rs index 5ace1a3157..cba9695eba 100644 --- a/codex-rs/ext/history-notes/tests/history_notes_extension.rs +++ b/codex-rs/ext/history-notes/tests/history_notes_extension.rs @@ -480,7 +480,7 @@ fn exposed_tools( registry: &ExtensionRegistry, session_store: &ExtensionData, thread_store: &ExtensionData, -) -> Vec ToolExecutor>>> { +) -> Vec> { registry .tool_contributors() .iter() diff --git a/codex-rs/ext/image-generation/src/extension.rs b/codex-rs/ext/image-generation/src/extension.rs index 14814aaeba..8923c44565 100644 --- a/codex-rs/ext/image-generation/src/extension.rs +++ b/codex-rs/ext/image-generation/src/extension.rs @@ -8,7 +8,6 @@ use codex_extension_api::ExtensionRegistryBuilder; use codex_extension_api::ThreadLifecycleContributor; use codex_extension_api::ThreadOriginator; use codex_extension_api::ThreadStartInput; -use codex_extension_api::ToolCall; use codex_extension_api::ToolContributor; use codex_extension_api::ToolExecutor; use codex_login::AuthManager; @@ -56,7 +55,7 @@ impl ToolContributor for ImageGenerationExtension { &self, _session_store: &ExtensionData, thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { let Some(config) = thread_store.get::() else { return Vec::new(); }; diff --git a/codex-rs/ext/image-generation/src/tool.rs b/codex-rs/ext/image-generation/src/tool.rs index c555cdd130..0e7719dc88 100644 --- a/codex-rs/ext/image-generation/src/tool.rs +++ b/codex-rs/ext/image-generation/src/tool.rs @@ -140,7 +140,7 @@ fn extension_turn_item(item: ImageGenerationItem, legacy_event: EventMsg) -> Ext } } -impl<'call> ToolExecutor> for ImageGenerationTool { +impl ToolExecutor for ImageGenerationTool { /// Keeps the tool in the existing image-generation Responses namespace. fn tool_name(&self) -> ToolName { ToolName::namespaced(IMAGE_GEN_NAMESPACE, IMAGEGEN_TOOL_NAME) @@ -156,10 +156,7 @@ impl<'call> ToolExecutor> for ImageGenerationTool { } /// Executes the selected image operation and returns the completed image result. - fn handle<'a>(&'a self, call: ToolCall<'call>) -> codex_extension_api::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> codex_extension_api::ToolExecutorFuture<'a> { Box::pin(self.handle_call(call)) } } diff --git a/codex-rs/ext/memories/src/extension.rs b/codex-rs/ext/memories/src/extension.rs index 3d68e6f708..20cf0da98c 100644 --- a/codex-rs/ext/memories/src/extension.rs +++ b/codex-rs/ext/memories/src/extension.rs @@ -13,6 +13,7 @@ use codex_extension_api::PromptFragment; use codex_extension_api::ThreadLifecycleContributor; use codex_extension_api::ThreadStartInput; use codex_extension_api::ToolContributor; +use codex_extension_api::ToolExecutor; use codex_features::Feature; use codex_otel::MetricsClient; use codex_protocol::MemoryVersion; @@ -139,9 +140,7 @@ impl ToolContributor for MemoriesExtension { &self, _session_store: &ExtensionData, thread_store: &ExtensionData, - ) -> Vec< - Arc codex_extension_api::ToolExecutor>>, - > { + ) -> Vec> { let Some(config) = thread_store.get::() else { return Vec::new(); }; diff --git a/codex-rs/ext/memories/src/tests.rs b/codex-rs/ext/memories/src/tests.rs index 8f226adea9..f11dea1573 100644 --- a/codex-rs/ext/memories/src/tests.rs +++ b/codex-rs/ext/memories/src/tests.rs @@ -598,10 +598,7 @@ async fn search_tool_rejects_legacy_single_query() { assert!(err.to_string().contains("query")); } -fn memory_tool( - memory_root: &Path, - tool_name: &str, -) -> Arc ToolExecutor>> { +fn memory_tool(memory_root: &Path, tool_name: &str) -> Arc { let expected_tool_name = memory_tool_name(tool_name); crate::tools::memory_tools( LocalMemoriesBackend::from_memory_root(memory_root), diff --git a/codex-rs/ext/memories/src/tools/ad_hoc_note.rs b/codex-rs/ext/memories/src/tools/ad_hoc_note.rs index 3adb1ddaf1..d670be46fe 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,7 @@ pub(super) struct AddAdHocNoteTool { pub(super) metrics_client: Option, } -impl<'call, B> ToolExecutor> for AddAdHocNoteTool +impl ToolExecutor for AddAdHocNoteTool where B: MemoriesBackend, { @@ -56,10 +56,7 @@ where ) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> codex_extension_api::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> codex_extension_api::ToolExecutorFuture<'a> { 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.rs index 375a6c0f66..e4106feff1 100644 --- a/codex-rs/ext/memories/src/tools/list.rs +++ b/codex-rs/ext/memories/src/tools/list.rs @@ -39,7 +39,7 @@ pub(super) struct ListTool { pub(super) metrics_client: Option, } -impl<'call, B> ToolExecutor> for ListTool +impl ToolExecutor for ListTool where B: MemoriesBackend, { @@ -58,10 +58,7 @@ where ) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> codex_extension_api::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> codex_extension_api::ToolExecutorFuture<'a> { Box::pin(self.handle_call(call)) } } diff --git a/codex-rs/ext/memories/src/tools/mod.rs b/codex-rs/ext/memories/src/tools/mod.rs index 2852e3c6a7..e73a370a00 100644 --- a/codex-rs/ext/memories/src/tools/mod.rs +++ b/codex-rs/ext/memories/src/tools/mod.rs @@ -28,7 +28,7 @@ mod search; pub(crate) fn memory_tools( backend: B, metrics_client: Option, -) -> Vec ToolExecutor>>> +) -> Vec> where B: MemoriesBackend, { diff --git a/codex-rs/ext/memories/src/tools/read.rs b/codex-rs/ext/memories/src/tools/read.rs index 152cd64777..a524f0a7be 100644 --- a/codex-rs/ext/memories/src/tools/read.rs +++ b/codex-rs/ext/memories/src/tools/read.rs @@ -38,7 +38,7 @@ pub(super) struct ReadTool { pub(super) metrics_client: Option, } -impl<'call, B> ToolExecutor> for ReadTool +impl ToolExecutor for ReadTool where B: MemoriesBackend, { @@ -57,10 +57,7 @@ where ) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> codex_extension_api::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> codex_extension_api::ToolExecutorFuture<'a> { 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.rs index 5f4f49ce9f..aa81e024d7 100644 --- a/codex-rs/ext/memories/src/tools/search.rs +++ b/codex-rs/ext/memories/src/tools/search.rs @@ -47,7 +47,7 @@ pub(super) struct SearchTool { pub(super) metrics_client: Option, } -impl<'call, B> ToolExecutor> for SearchTool +impl ToolExecutor for SearchTool where B: MemoriesBackend, { @@ -66,10 +66,7 @@ where ) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> codex_extension_api::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> codex_extension_api::ToolExecutorFuture<'a> { Box::pin(self.handle_call(call)) } } diff --git a/codex-rs/ext/multi-env-copy-file/src/extension.rs b/codex-rs/ext/multi-env-copy-file/src/extension.rs index 7e55c0414e..94836e7adf 100644 --- a/codex-rs/ext/multi-env-copy-file/src/extension.rs +++ b/codex-rs/ext/multi-env-copy-file/src/extension.rs @@ -4,7 +4,6 @@ use std::sync::Arc; use codex_extension_api::ExtensionData; use codex_extension_api::ExtensionRegistryBuilder; -use codex_extension_api::ToolCall; use codex_extension_api::ToolContributor; use codex_extension_api::ToolExecutor; @@ -17,7 +16,7 @@ impl ToolContributor for FileCopyExtension { &self, _session_store: &ExtensionData, _thread_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { vec![Arc::new(CopyFileTool)] } } diff --git a/codex-rs/ext/multi-env-copy-file/src/tool.rs b/codex-rs/ext/multi-env-copy-file/src/tool.rs index ac60a7e405..503b20adbe 100644 --- a/codex-rs/ext/multi-env-copy-file/src/tool.rs +++ b/codex-rs/ext/multi-env-copy-file/src/tool.rs @@ -39,7 +39,7 @@ impl CopyFileArgs { } } -impl<'call> ToolExecutor> for CopyFileTool { +impl ToolExecutor for CopyFileTool { fn tool_name(&self) -> ToolName { ToolName::plain(TOOL_NAME) } @@ -107,10 +107,7 @@ impl<'call> ToolExecutor> for CopyFileTool { ]) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> codex_tools::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> codex_tools::ToolExecutorFuture<'a> { Box::pin(async move { let args = CopyFileArgs::parse(call.function_arguments()?)?; let [source, target] = call.environments.as_slice() else { diff --git a/codex-rs/ext/skills/src/extension.rs b/codex-rs/ext/skills/src/extension.rs index 2abd665717..c9abd4aca4 100644 --- a/codex-rs/ext/skills/src/extension.rs +++ b/codex-rs/ext/skills/src/extension.rs @@ -18,7 +18,6 @@ use codex_extension_api::PromptSlot; use codex_extension_api::SkillInvocationContributor; use codex_extension_api::ThreadLifecycleContributor; use codex_extension_api::ThreadStartInput; -use codex_extension_api::ToolCall; use codex_extension_api::ToolContributor; use codex_extension_api::ToolExecutor; use codex_extension_api::TurnInputContext; @@ -282,7 +281,7 @@ where session_store: &ExtensionData, thread_store: &ExtensionData, step_store: &ExtensionData, - ) -> Vec ToolExecutor>>> { + ) -> Vec> { skill_tools( self.providers.clone(), session_store, diff --git a/codex-rs/ext/skills/src/tools/installations.rs b/codex-rs/ext/skills/src/tools/installations.rs index f26d4b05a7..93657e22b7 100644 --- a/codex-rs/ext/skills/src/tools/installations.rs +++ b/codex-rs/ext/skills/src/tools/installations.rs @@ -54,7 +54,7 @@ pub(super) struct InstallationsTool { pub(super) metrics: Option>, } -impl<'call> ToolExecutor> for InstallationsTool { +impl ToolExecutor for InstallationsTool { fn tool_name(&self) -> ToolName { skill_tool_name(TOOL_NAME) } @@ -70,10 +70,7 @@ impl<'call> ToolExecutor> for InstallationsTool { ) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let mut outcome = "internal_error"; let mut source_filter = "unparsed"; diff --git a/codex-rs/ext/skills/src/tools/list.rs b/codex-rs/ext/skills/src/tools/list.rs index da15e3fc3d..07c2e7f80b 100644 --- a/codex-rs/ext/skills/src/tools/list.rs +++ b/codex-rs/ext/skills/src/tools/list.rs @@ -63,7 +63,7 @@ pub(super) struct ListTool { pub(super) context: SkillToolContext, } -impl<'call> ToolExecutor> for ListTool { +impl ToolExecutor for ListTool { fn tool_name(&self) -> ToolName { skill_tool_name(TOOL_NAME) } @@ -79,10 +79,7 @@ impl<'call> ToolExecutor> for ListTool { ) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let args: ListArgs = parse_args(&call)?; let response_byte_budget = call.response_byte_budget(MAX_SKILL_RESPONSE_BYTES); diff --git a/codex-rs/ext/skills/src/tools/mod.rs b/codex-rs/ext/skills/src/tools/mod.rs index 8032e64dcb..82deab50f6 100644 --- a/codex-rs/ext/skills/src/tools/mod.rs +++ b/codex-rs/ext/skills/src/tools/mod.rs @@ -59,7 +59,7 @@ pub(crate) fn skill_tools( session_store: &ExtensionData, thread_store: &ExtensionData, step_store: &ExtensionData, -) -> Vec ToolExecutor>>> { +) -> Vec> { let Some(thread_state) = thread_store.get::() else { return Vec::new(); }; @@ -84,7 +84,7 @@ pub(crate) fn skill_tools( analytics, step_state, }; - let mut tools: Vec ToolExecutor>>> = vec![ + let mut tools: Vec> = vec![ Arc::new(list::ListTool { context: context.clone(), }), diff --git a/codex-rs/ext/skills/src/tools/read.rs b/codex-rs/ext/skills/src/tools/read.rs index bce8338e59..a2ac7a4e8e 100644 --- a/codex-rs/ext/skills/src/tools/read.rs +++ b/codex-rs/ext/skills/src/tools/read.rs @@ -90,7 +90,7 @@ pub(super) struct ReadTool { pub(super) metrics: Option>, } -impl<'call> ToolExecutor> for ReadTool { +impl ToolExecutor for ReadTool { fn tool_name(&self) -> ToolName { skill_tool_name(TOOL_NAME) } @@ -112,10 +112,7 @@ impl<'call> ToolExecutor> for ReadTool { ) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let mut outcome = "internal_error"; let result = async { diff --git a/codex-rs/ext/skills/tests/skills_extension/merge_catalog_tests.rs b/codex-rs/ext/skills/tests/skills_extension/merge_catalog_tests.rs index 436c3ccadf..3c1b75a98c 100644 --- a/codex-rs/ext/skills/tests/skills_extension/merge_catalog_tests.rs +++ b/codex-rs/ext/skills/tests/skills_extension/merge_catalog_tests.rs @@ -133,10 +133,7 @@ impl MergeHarness { Ok(harness) } - async fn tools( - &self, - step: &ExtensionData, - ) -> Vec ToolExecutor>>> { + async fn tools(&self, step: &ExtensionData) -> Vec> { step.get_or_init(|| self.catalog_metrics.clone() as Arc); if let Some(snapshots) = &self.snapshots { step.insert(snapshots.clone()); @@ -220,7 +217,7 @@ impl MergeHarness { } pub(super) async fn call_tool( - tools: &[Arc ToolExecutor>>], + tools: &[Arc], name: &str, arguments: Value, ) -> Result { @@ -228,7 +225,7 @@ pub(super) async fn call_tool( } async fn call_tool_with_budget( - tools: &[Arc ToolExecutor>>], + tools: &[Arc], name: &str, arguments: Value, truncation_policy: TruncationPolicy, diff --git a/codex-rs/ext/web-search/src/extension.rs b/codex-rs/ext/web-search/src/extension.rs index f5e172437d..3796bd0dfb 100644 --- a/codex-rs/ext/web-search/src/extension.rs +++ b/codex-rs/ext/web-search/src/extension.rs @@ -17,6 +17,7 @@ use codex_extension_api::ThreadLifecycleContributor; use codex_extension_api::ThreadOriginator; use codex_extension_api::ThreadStartInput; use codex_extension_api::ToolContributor; +use codex_extension_api::ToolExecutor; use codex_http_client::HttpClientFactory; use codex_login::AuthManager; use codex_model_provider::WorkspaceRoutingContext; @@ -123,9 +124,7 @@ impl ToolContributor for WebSearchExtension { session_store: &ExtensionData, thread_store: &ExtensionData, step_store: &ExtensionData, - ) -> Vec< - Arc codex_extension_api::ToolExecutor>>, - > { + ) -> Vec> { let (Some(config), Some(workspace_routing), Some(mode)) = ( thread_store.get::(), thread_store.get::(), diff --git a/codex-rs/ext/web-search/src/tool.rs b/codex-rs/ext/web-search/src/tool.rs index 34b00c3ed2..d0eefcbe7c 100644 --- a/codex-rs/ext/web-search/src/tool.rs +++ b/codex-rs/ext/web-search/src/tool.rs @@ -61,7 +61,7 @@ pub(crate) struct WebSearchTool { pub(crate) originator: Option, } -impl<'call> ToolExecutor> for WebSearchTool { +impl ToolExecutor for WebSearchTool { fn tool_name(&self) -> ToolName { ToolName::namespaced(WEB_NAMESPACE, RUN_TOOL_NAME) } @@ -96,10 +96,7 @@ impl<'call> ToolExecutor> for WebSearchTool { true } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> codex_extension_api::ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> codex_extension_api::ToolExecutorFuture<'a> { Box::pin(self.handle_call(call)) } } diff --git a/codex-rs/message-board-mcp/src/lib.rs b/codex-rs/message-board-mcp/src/lib.rs index 976a77b2ea..8122c456ca 100644 --- a/codex-rs/message-board-mcp/src/lib.rs +++ b/codex-rs/message-board-mcp/src/lib.rs @@ -52,7 +52,7 @@ use uuid::Uuid; /// The board's host continues to handle notifications; this service adds no /// Core delivery, lifecycle registration, or MCP push notifications. pub struct MessageBoardMcpServer { - tools: Vec ToolExecutor>>>, + tools: Vec>, invocation_scope: String, } diff --git a/codex-rs/message-board/src/tools.rs b/codex-rs/message-board/src/tools.rs index bd778a97de..02935cc455 100644 --- a/codex-rs/message-board/src/tools.rs +++ b/codex-rs/message-board/src/tools.rs @@ -58,7 +58,7 @@ pub fn message_board_tools( namespace: Option<&str>, namespace_description: &str, tool_messages: Option<&MultiAgentToolMessages>, -) -> Vec ToolExecutor>>> { +) -> Vec> { tools .iter() .map(|&tool| { @@ -78,7 +78,7 @@ pub fn message_board_tools( namespace: namespace.map(str::to_owned), namespace_description: namespace_description.to_owned(), description: tool_message.and_then(|tool| tool.description.clone()), - }) as Arc ToolExecutor>> + }) as Arc }) .collect() } @@ -93,7 +93,7 @@ struct BoardTool { description: Option, } -impl<'call> ToolExecutor> for BoardTool { +impl ToolExecutor for BoardTool { fn tool_name(&self) -> ToolName { ToolName::new(self.namespace.clone(), self.tool.name()) } @@ -109,10 +109,7 @@ impl<'call> ToolExecutor> for BoardTool { MessageBoardTool::READ_ONLY.contains(&self.tool) } - fn handle<'a>(&'a self, call: ToolCall<'call>) -> ToolExecutorFuture<'a> - where - 'call: 'a, - { + fn handle<'a>(&'a self, call: ToolCall<'a>) -> ToolExecutorFuture<'a> { Box::pin(async move { let raw = call.function_arguments()?; if raw.len() > MAX_TOOL_ARGUMENT_KIB * 1024 { diff --git a/codex-rs/tools/src/lib.rs b/codex-rs/tools/src/lib.rs index 48740882ab..bed691b4a3 100644 --- a/codex-rs/tools/src/lib.rs +++ b/codex-rs/tools/src/lib.rs @@ -98,10 +98,12 @@ pub use tool_discovery::TOOL_SEARCH_TOOL_NAME; 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::BorrowedToolCall; pub use tool_executor::ToolExecutor; pub use tool_executor::ToolExecutorFuture; pub use tool_executor::ToolExposure; pub use tool_executor::ToolExposures; +pub use tool_executor::ToolInput; pub use tool_output::JsonToolOutput; pub use tool_output::ToolOutput; pub use tool_payload::ToolPayload; diff --git a/codex-rs/tools/src/tool_executor.rs b/codex-rs/tools/src/tool_executor.rs index f2a1bca43a..c4009c84cf 100644 --- a/codex-rs/tools/src/tool_executor.rs +++ b/codex-rs/tools/src/tool_executor.rs @@ -98,12 +98,25 @@ impl ToolExposure { } } +/// Selects the input a tool receives for the lifetime of one call. +/// Keeping the associated type here lets `ToolExecutor` remain dyn-compatible. +pub trait ToolInput { + type Call<'a>: 'a; +} + +/// Extension tools borrow host capabilities for the duration of the call. +pub enum BorrowedToolCall {} + +impl ToolInput for BorrowedToolCall { + type Call<'a> = crate::ToolCall<'a>; +} + /// Shared runtime contract for model-visible tools. /// /// 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. -pub trait ToolExecutor: Send + Sync { +pub trait ToolExecutor: Send + Sync { /// The concrete tool name handled by this runtime instance. fn tool_name(&self) -> ToolName; @@ -133,7 +146,5 @@ pub trait ToolExecutor: Send + Sync { } /// Handles one invocation without retaining capabilities borrowed by the host. - fn handle<'a>(&'a self, invocation: Invocation) -> ToolExecutorFuture<'a> - where - Invocation: 'a; + fn handle<'a>(&'a self, invocation: Input::Call<'a>) -> ToolExecutorFuture<'a>; }