[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

@@ -41,7 +41,6 @@ pub(super) struct AddAdHocNoteTool<B> {
pub(super) metrics_client: Option<MetricsClient>,
}
#[async_trait::async_trait]
impl<B> ToolExecutor<ToolCall> for AddAdHocNoteTool<B>
where
B: MemoriesBackend,
@@ -57,12 +56,8 @@ where
)
}
async fn handle(
&self,
call: ToolCall,
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
{
self.handle_call(call).await
fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {
Box::pin(self.handle_call(call))
}
}
+2 -7
View File
@@ -39,7 +39,6 @@ pub(super) struct ListTool<B> {
pub(super) metrics_client: Option<MetricsClient>,
}
#[async_trait::async_trait]
impl<B> ToolExecutor<ToolCall> for ListTool<B>
where
B: MemoriesBackend,
@@ -55,12 +54,8 @@ where
)
}
async fn handle(
&self,
call: ToolCall,
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
{
self.handle_call(call).await
fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {
Box::pin(self.handle_call(call))
}
}
+2 -7
View File
@@ -38,7 +38,6 @@ pub(super) struct ReadTool<B> {
pub(super) metrics_client: Option<MetricsClient>,
}
#[async_trait::async_trait]
impl<B> ToolExecutor<ToolCall> for ReadTool<B>
where
B: MemoriesBackend,
@@ -54,12 +53,8 @@ where
)
}
async fn handle(
&self,
call: ToolCall,
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
{
self.handle_call(call).await
fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {
Box::pin(self.handle_call(call))
}
}
+2 -7
View File
@@ -47,7 +47,6 @@ pub(super) struct SearchTool<B> {
pub(super) metrics_client: Option<MetricsClient>,
}
#[async_trait::async_trait]
impl<B> ToolExecutor<ToolCall> for SearchTool<B>
where
B: MemoriesBackend,
@@ -63,12 +62,8 @@ where
)
}
async fn handle(
&self,
call: ToolCall,
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
{
self.handle_call(call).await
fn handle(&self, call: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {
Box::pin(self.handle_call(call))
}
}