[codex] Remove async_trait from ToolExecutor (#27304)

## Why

We're now [discouraging use of
`async_trait`](https://github.com/openai/codex/pull/20242).

Removing use of `async_trait` from `ToolExecutor` yields a `codex_core`
debug test build speedup of ~78% (from 227.5s to 50.3s) on my machine.

Stacked on #27299, this PR applies the trait change after the handler
bodies have been outlined.

## What

Changed `ToolExecutor::handle` to return an explicit boxed
`ToolExecutorFuture` instead of using `async_trait`.

Updated ToolExecutor implementors to return `Box::pin(...)`, reexported
the future alias through `codex-tools` and `codex-extension-api`, and
removed `codex-tools` direct `async-trait` dependency.
This commit is contained in:
Adam Perry @ OpenAI authored and GitHub committed 2026-06-10 10:26:53 -07:00
1 parent d3abd8774e
commit 2704ecea9a
56 files changed
+161 -357

No files matched your search

@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
+2 -6
View File
@@ -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))
}
}
@@ -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>,
)
}
}
@@ -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))
}
}
+2 -6
View File
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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) })
}
}
@@ -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) })
}
}
@@ -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))
}
}
@@ -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) })
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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)
})
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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) })
}
}
@@ -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))
}
}
+2 -6
View File
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}
@@ -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))
}
}