mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
[codex] Outline ToolExecutor handler bodies (#27299)
## 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. For ease of reviewing, this is a prefactor to extract trait method implementations to inherent methods. This will prevent changing indentation from creating a huge diff. ## What Outlined existing `ToolExecutor::handle` bodies into inherent async `handle_call` methods across core and extension tool handlers. The trait methods still use `async_trait` and now delegate to `self.handle_call(...).await`; handler behavior is unchanged.
This commit is contained in:
committed by
GitHub
Unverified
parent
c365b8a4ab
commit
db531b4a6c
@@ -104,6 +104,15 @@ impl ToolExecutor<ToolInvocation> for CodeModeExecuteHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl CodeModeExecuteHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -57,6 +57,15 @@ impl ToolExecutor<ToolInvocation> for CodeModeWaitHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl CodeModeWaitHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -26,6 +26,15 @@ impl ToolExecutor<ToolInvocation> for ReportAgentJobResultHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ReportAgentJobResultHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session, payload, ..
|
||||
|
||||
@@ -27,6 +27,15 @@ impl ToolExecutor<ToolInvocation> for SpawnAgentsOnCsvHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl SpawnAgentsOnCsvHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -318,6 +318,15 @@ impl ToolExecutor<ToolInvocation> for ApplyPatchHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ApplyPatchHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -89,6 +89,15 @@ impl ToolExecutor<ToolInvocation> for DynamicToolHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl DynamicToolHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -221,6 +221,15 @@ mod tests {
|
||||
async fn handle(
|
||||
&self,
|
||||
call: codex_tools::ToolCall,
|
||||
) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl CapturingExtensionExecutor {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
call: codex_tools::ToolCall,
|
||||
) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {
|
||||
let item = ExtensionTurnItem::WebSearch(WebSearchItem {
|
||||
id: call.call_id.clone(),
|
||||
@@ -452,6 +461,15 @@ mod tests {
|
||||
async fn handle(
|
||||
&self,
|
||||
call: codex_tools::ToolCall,
|
||||
) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ImageGenerationExtensionExecutor {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
call: codex_tools::ToolCall,
|
||||
) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {
|
||||
call.turn_item_emitter
|
||||
.emit_started(ExtensionTurnItem::ImageGeneration(
|
||||
|
||||
@@ -71,6 +71,15 @@ impl ToolExecutor<ToolInvocation> for ListAvailablePluginsToInstallHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ListAvailablePluginsToInstallHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation { payload, .. } = invocation;
|
||||
match payload {
|
||||
|
||||
@@ -116,6 +116,15 @@ impl ToolExecutor<ToolInvocation> for McpHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl McpHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -43,6 +43,15 @@ impl ToolExecutor<ToolInvocation> for ListMcpResourceTemplatesHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ListMcpResourceTemplatesHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -43,6 +43,15 @@ impl ToolExecutor<ToolInvocation> for ListMcpResourcesHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ListMcpResourcesHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -43,6 +43,15 @@ impl ToolExecutor<ToolInvocation> for ReadMcpResourceHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ReadMcpResourceHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -26,6 +26,15 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -47,6 +47,15 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -20,6 +20,15 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let arguments = function_arguments(invocation.payload.clone())?;
|
||||
let args: FollowupTaskArgs = parse_arguments(&arguments)?;
|
||||
|
||||
@@ -18,6 +18,15 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -20,6 +20,15 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let arguments = function_arguments(invocation.payload.clone())?;
|
||||
let args: SendMessageArgs = parse_arguments(&arguments)?;
|
||||
|
||||
@@ -32,6 +32,15 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl Handler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -58,6 +58,15 @@ impl ToolExecutor<ToolInvocation> for PlanHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl PlanHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -38,6 +38,15 @@ impl ToolExecutor<ToolInvocation> for RequestPermissionsHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl RequestPermissionsHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -65,6 +65,15 @@ impl ToolExecutor<ToolInvocation> for RequestPluginInstallHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl RequestPluginInstallHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
payload,
|
||||
|
||||
@@ -33,6 +33,15 @@ impl ToolExecutor<ToolInvocation> for RequestUserInputHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl RequestUserInputHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -144,6 +144,15 @@ impl ToolExecutor<ToolInvocation> for ShellCommandHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ShellCommandHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -74,6 +74,15 @@ impl ToolExecutor<ToolInvocation> for TestSyncHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl TestSyncHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation { payload, .. } = invocation;
|
||||
|
||||
|
||||
@@ -70,6 +70,15 @@ impl ToolExecutor<ToolInvocation> for ToolSearchHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolSearchHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation { payload, .. } = invocation;
|
||||
|
||||
|
||||
@@ -95,6 +95,15 @@ impl ToolExecutor<ToolInvocation> for ExecCommandHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ExecCommandHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -44,6 +44,15 @@ impl ToolExecutor<ToolInvocation> for WriteStdinHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl WriteStdinHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -81,6 +81,15 @@ impl ToolExecutor<ToolInvocation> for ViewImageHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ViewImageHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
if !invocation
|
||||
.turn
|
||||
|
||||
@@ -314,6 +314,15 @@ mod tests {
|
||||
async fn handle(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(invocation).await
|
||||
}
|
||||
}
|
||||
|
||||
impl CancellationCleanupHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
let started = self
|
||||
.started
|
||||
|
||||
@@ -51,6 +51,14 @@ impl ToolExecutor<ToolInvocation> for LifecycleTestHandler {
|
||||
async fn handle(
|
||||
&self,
|
||||
_invocation: ToolInvocation,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
self.handle_call().await
|
||||
}
|
||||
}
|
||||
|
||||
impl LifecycleTestHandler {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
) -> Result<Box<dyn crate::tools::context::ToolOutput>, FunctionCallError> {
|
||||
match self.result.clone() {
|
||||
LifecycleTestResult::Ok { success } => Ok(Box::new(
|
||||
|
||||
@@ -76,6 +76,15 @@ impl ToolExecutor<ExtensionToolCall> for ExtensionEchoExecutor {
|
||||
async fn handle(
|
||||
&self,
|
||||
call: ExtensionToolCall,
|
||||
) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtensionEchoExecutor {
|
||||
async fn handle_call(
|
||||
&self,
|
||||
call: ExtensionToolCall,
|
||||
) -> Result<Box<dyn codex_tools::ToolOutput>, codex_tools::FunctionCallError> {
|
||||
let arguments: serde_json::Value =
|
||||
serde_json::from_str(call.function_arguments()?).expect("test arguments should parse");
|
||||
|
||||
@@ -97,6 +97,12 @@ impl ToolExecutor<ToolCall> for ImageGenerationTool {
|
||||
|
||||
/// Executes the selected image operation and returns the completed image result.
|
||||
async fn handle(&self, call: ToolCall) -> Result<Box<dyn ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl ImageGenerationTool {
|
||||
async fn handle_call(&self, call: ToolCall) -> Result<Box<dyn ToolOutput>, FunctionCallError> {
|
||||
let args = parse_args(&call)?;
|
||||
let request = request_for_args(&args, call.conversation_history.items())?;
|
||||
call.turn_item_emitter
|
||||
|
||||
@@ -61,6 +61,19 @@ where
|
||||
&self,
|
||||
call: ToolCall,
|
||||
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
|
||||
{
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> AddAdHocNoteTool<B>
|
||||
where
|
||||
B: MemoriesBackend,
|
||||
{
|
||||
async fn handle_call(
|
||||
&self,
|
||||
call: ToolCall,
|
||||
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
|
||||
{
|
||||
let backend = self.backend.clone();
|
||||
let args: AddAdHocNoteArgs = parse_args(&call)?;
|
||||
|
||||
@@ -59,6 +59,19 @@ where
|
||||
&self,
|
||||
call: ToolCall,
|
||||
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
|
||||
{
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> ListTool<B>
|
||||
where
|
||||
B: MemoriesBackend,
|
||||
{
|
||||
async fn handle_call(
|
||||
&self,
|
||||
call: ToolCall,
|
||||
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
|
||||
{
|
||||
let backend = self.backend.clone();
|
||||
let args: ListArgs = parse_args(&call)?;
|
||||
|
||||
@@ -58,6 +58,19 @@ where
|
||||
&self,
|
||||
call: ToolCall,
|
||||
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
|
||||
{
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> ReadTool<B>
|
||||
where
|
||||
B: MemoriesBackend,
|
||||
{
|
||||
async fn handle_call(
|
||||
&self,
|
||||
call: ToolCall,
|
||||
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
|
||||
{
|
||||
let backend = self.backend.clone();
|
||||
let args: ReadArgs = parse_args(&call)?;
|
||||
|
||||
@@ -67,6 +67,19 @@ where
|
||||
&self,
|
||||
call: ToolCall,
|
||||
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
|
||||
{
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<B> SearchTool<B>
|
||||
where
|
||||
B: MemoriesBackend,
|
||||
{
|
||||
async fn handle_call(
|
||||
&self,
|
||||
call: ToolCall,
|
||||
) -> Result<Box<dyn codex_extension_api::ToolOutput>, codex_extension_api::FunctionCallError>
|
||||
{
|
||||
let backend = self.backend.clone();
|
||||
let args: SearchArgs = parse_args(&call)?;
|
||||
|
||||
@@ -75,6 +75,12 @@ impl ToolExecutor<ToolCall> for WebSearchTool {
|
||||
}
|
||||
|
||||
async fn handle(&self, call: ToolCall) -> Result<Box<dyn ToolOutput>, FunctionCallError> {
|
||||
self.handle_call(call).await
|
||||
}
|
||||
}
|
||||
|
||||
impl WebSearchTool {
|
||||
async fn handle_call(&self, call: ToolCall) -> Result<Box<dyn ToolOutput>, FunctionCallError> {
|
||||
let commands = parse_commands(&call)?;
|
||||
let command_action = command_action(&commands);
|
||||
let provider = self
|
||||
|
||||
Reference in New Issue
Block a user