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
+4 -7
View File
@@ -8185,7 +8185,7 @@ impl ToolContributor for NamespacedCustomTool {
&self,
_session_store: &ExtensionData,
_thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
Vec::new()
}
@@ -8194,7 +8194,7 @@ impl ToolContributor for NamespacedCustomTool {
_session_store: &ExtensionData,
_thread_store: &ExtensionData,
_step_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
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<ToolCall<'call>> for NamespacedCustomTool {
impl ToolExecutor for NamespacedCustomTool {
fn tool_name(&self) -> ToolName {
ToolName::namespaced("editor", "apply_patch")
}
@@ -8224,10 +8224,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> 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(