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<dyn ToolExecutor>`. Core handlers continue to take owned
`ToolInvocation` inputs.

GitOrigin-RevId: efbf56c1e758c59a18b192d210c2ab1b368793e2
This commit is contained in:
jif
2026-11-26 14:27:37 +00:00
committed by copyberry
parent ad7176f787
commit 7ca4eada90
88 changed files with 173 additions and 401 deletions
@@ -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<C> ToolContributor for ImageGenerationExtension<C> {
&self,
_session_store: &ExtensionData,
thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
let Some(config) = thread_store.get::<ImageGenerationExtensionConfig>() else {
return Vec::new();
};
+2 -5
View File
@@ -140,7 +140,7 @@ fn extension_turn_item(item: ImageGenerationItem, legacy_event: EventMsg) -> Ext
}
}
impl<'call> ToolExecutor<ToolCall<'call>> 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<ToolCall<'call>> 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))
}
}