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
@@ -22,7 +22,6 @@ use codex_protocol::ThreadId;
use codex_protocol::error::CodexErr;
use codex_protocol::error::Result;
use codex_protocol::openai_models::MultiAgentToolMessages;
use codex_tools::ToolCall;
use codex_tools::ToolExecutor;
use futures::future::BoxFuture;
use std::sync::Arc;
@@ -102,7 +101,7 @@ impl<C: Sync> ToolContributor for BoardExtension<C> {
&self,
_session_store: &ExtensionData,
thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
self.tools_with_descriptions(thread_store, /*tool_messages*/ None)
}
@@ -111,7 +110,7 @@ impl<C: Sync> ToolContributor for BoardExtension<C> {
_session_store: &ExtensionData,
thread_store: &ExtensionData,
step_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
let tool_messages = step_store.get::<MultiAgentToolMessages>();
self.tools_with_descriptions(thread_store, tool_messages.as_deref())
}
@@ -122,7 +121,7 @@ impl<C> BoardExtension<C> {
&self,
thread_store: &ExtensionData,
tool_messages: Option<&MultiAgentToolMessages>,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
thread_store
.get::<Binding>()
.map_or_else(Vec::new, |binding| {
@@ -10,7 +10,6 @@ use codex_exec_server_protocol::ExecutorCapabilityDiscoveryV2Snapshot;
use codex_protocol::capabilities::SelectedCapabilityRoot;
use codex_protocol::items::TurnItem;
use codex_protocol::protocol::TokenUsageInfo;
use codex_tools::ToolCall;
use codex_tools::ToolExecutor;
use crate::ExtensionData;
@@ -429,7 +428,7 @@ pub trait ToolContributor: Send + Sync {
&self,
_session_store: &ExtensionData,
_thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
Vec::new()
}
@@ -439,7 +438,7 @@ pub trait ToolContributor: Send + Sync {
session_store: &ExtensionData,
thread_store: &ExtensionData,
_step_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
self.tools(session_store, thread_store)
}
}
+1 -2
View File
@@ -22,7 +22,6 @@ use codex_extension_api::ResponseItem;
use codex_extension_api::SkillInvocationContributor;
use codex_extension_api::ThreadLifecycleContributor;
use codex_extension_api::TokenUsageContributor;
use codex_extension_api::ToolCall;
use codex_extension_api::ToolContributor;
use codex_extension_api::ToolExecutor;
use codex_extension_api::ToolLifecycleContributor;
@@ -179,7 +178,7 @@ impl ToolContributor for AllContributors {
&self,
_session_store: &ExtensionData,
_thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
Vec::new()
}
}
+2 -5
View File
@@ -15,7 +15,6 @@ use codex_extension_api::ThreadResumeInput;
use codex_extension_api::ThreadStartInput;
use codex_extension_api::ThreadStopInput;
use codex_extension_api::TokenUsageContributor;
use codex_extension_api::ToolCall;
use codex_extension_api::ToolCallOutcome;
use codex_extension_api::ToolContributor;
use codex_extension_api::ToolExecutor;
@@ -560,9 +559,7 @@ where
&self,
_session_store: &ExtensionData,
thread_store: &ExtensionData,
) -> Vec<
Arc<dyn for<'call> codex_extension_api::ToolExecutor<codex_extension_api::ToolCall<'call>>>,
> {
) -> Vec<Arc<dyn ToolExecutor>> {
let Some(runtime) = goal_runtime_handle(thread_store) else {
return Vec::new();
};
@@ -603,7 +600,7 @@ where
.into_iter()
.map(|mut tool| {
tool.execution_allowed = runtime.tools_available();
Arc::new(tool) as Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>
Arc::new(tool) as Arc<dyn ToolExecutor>
})
.collect()
}
+3 -6
View File
@@ -142,7 +142,7 @@ impl GoalToolExecutor {
}
}
impl<'call> ToolExecutor<ToolCall<'call>> for GoalToolExecutor {
impl ToolExecutor for GoalToolExecutor {
fn tool_name(&self) -> ToolName {
ToolName::plain(match self.kind {
GoalToolKind::Get => GET_GOAL_TOOL_NAME,
@@ -165,11 +165,8 @@ impl<'call> ToolExecutor<ToolCall<'call>> for GoalToolExecutor {
fn handle<'a>(
&'a self,
invocation: ToolCall<'call>,
) -> codex_extension_api::ToolExecutorFuture<'a>
where
'call: 'a,
{
invocation: ToolCall<'a>,
) -> codex_extension_api::ToolExecutorFuture<'a> {
Box::pin(async move {
if !self.execution_allowed {
return Err(FunctionCallError::RespondToModel(
@@ -1637,7 +1637,7 @@ async fn goal_service_enforces_maximum_token_budget_on_creation_and_updates() ->
async fn installed_tools(
runtime: Arc<codex_state::StateRuntime>,
thread_id: ThreadId,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
installed_tools_with_start(
runtime,
thread_id,
@@ -1652,7 +1652,7 @@ async fn installed_tools_with_start(
thread_id: ThreadId,
session_source: SessionSource,
persistent_thread_state_available: bool,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
let mut builder = ExtensionRegistryBuilder::<()>::new();
let goal_service = Arc::new(GoalService::new());
install_with_backend(
@@ -1692,7 +1692,7 @@ async fn installed_tools_with_start(
.collect()
}
fn tool_names(tools: &[Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>]) -> Vec<String> {
fn tool_names(tools: &[Arc<dyn ToolExecutor>]) -> Vec<String> {
tools.iter().map(|tool| tool.tool_name().name).collect()
}
@@ -1794,7 +1794,7 @@ impl GoalExtensionHarness {
})
}
fn tools(&self) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
fn tools(&self) -> Vec<Arc<dyn ToolExecutor>> {
self.registry
.tool_contributors()
.iter()
@@ -1948,10 +1948,7 @@ impl GoalExtensionHarness {
}
}
fn tool_by_name<'a>(
tools: &'a [Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>],
name: &str,
) -> &'a Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>> {
fn tool_by_name<'a>(tools: &'a [Arc<dyn ToolExecutor>], name: &str) -> &'a Arc<dyn ToolExecutor> {
tools
.iter()
.find(|tool| tool.tool_name().namespace.is_none() && tool.tool_name().name == name)
@@ -8,7 +8,6 @@ use std::sync::Weak;
use codex_core::CodexThread;
use codex_extension_api::ExtensionData;
use codex_extension_api::ExtensionFuture;
use codex_extension_api::ToolCall;
use codex_extension_api::ToolContributor;
use codex_extension_api::ToolExecutor;
use codex_extension_api::TurnLifecycleContributor;
@@ -19,7 +18,7 @@ pub(super) struct ConversationHistoryTools {
pub parent: Weak<CodexThread>,
}
struct HistoryTools(Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>>);
struct HistoryTools(Vec<Arc<dyn ToolExecutor>>);
impl TurnLifecycleContributor for ConversationHistoryTools {
fn turn_start_phase(&self, _thread_store: &ExtensionData) -> TurnStartPhase {
@@ -54,7 +53,7 @@ impl ToolContributor for ConversationHistoryTools {
&self,
_session_store: &ExtensionData,
thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
thread_store
.get::<HistoryTools>()
.map(|tools| tools.0.clone())
@@ -11,7 +11,6 @@ use codex_message_board::MessageBoardTool;
use codex_message_board::message_board_tools;
use codex_protocol::AgentPath;
use codex_protocol::ThreadId;
use codex_tools::ToolCall;
use codex_tools::ToolExecutor;
use codex_tools::ToolName;
use std::sync::Arc;
@@ -69,7 +68,7 @@ impl LiveRetrievalBinding {
.map(|name| ToolName::namespaced(NAMESPACE, name))
}
pub fn tools(&self) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
pub fn tools(&self) -> Vec<Arc<dyn ToolExecutor>> {
let mut tools = message_board_tools(
&LIVE_READ_TOOLS,
self.board.clone(),
@@ -94,7 +93,7 @@ impl ToolContributor for RetrievalTools {
&self,
_session: &ExtensionData,
thread: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
thread
.get::<LiveRetrievalBinding>()
.map_or_else(Vec::new, |binding| binding.tools())
@@ -77,7 +77,7 @@ pub(super) fn tools(
path: &AgentPath,
namespace: &str,
namespace_description: &str,
) -> impl Iterator<Item = Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> impl Iterator<Item = Arc<dyn ToolExecutor>> {
TOOLS
.into_iter()
.map(move |(name, description, operation)| {
@@ -111,11 +111,11 @@ pub(super) fn tools(
operation,
name,
spec,
}) as Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>
}) as Arc<dyn ToolExecutor>
})
}
impl<'call> ToolExecutor<ToolCall<'call>> for SubscriptionTool {
impl ToolExecutor for SubscriptionTool {
fn tool_name(&self) -> ToolName {
self.name.clone()
}
@@ -128,10 +128,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for SubscriptionTool {
matches!(self.operation, Operation::List)
}
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 raw = call.function_arguments()?;
if raw.len() > MAX_TOOL_ARGUMENT_KIB * 1024 {
+3 -6
View File
@@ -49,7 +49,7 @@ use serde_json::json;
use std::marker::PhantomData;
use std::sync::Arc;
pub(crate) type Executor = Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>;
pub(crate) type Executor = Arc<dyn ToolExecutor>;
// Keep the catalog key, tool name, request type and HTTP route in one registration.
macro_rules! register_tools {
@@ -154,7 +154,7 @@ struct HistoryNotesTool<R, B> {
spec: ToolSpec,
}
impl<'call, R: Request, B: Handle<R>> ToolExecutor<ToolCall<'call>> for HistoryNotesTool<R, B> {
impl<R: Request, B: Handle<R>> ToolExecutor for HistoryNotesTool<R, B> {
fn tool_name(&self) -> ToolName {
ToolName::namespaced(R::NAMESPACE.name, R::NAME)
}
@@ -171,10 +171,7 @@ impl<'call, R: Request, B: Handle<R>> ToolExecutor<ToolCall<'call>> for HistoryN
R::PARALLEL
}
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 input = parse_arguments(call.function_arguments()?)?;
let response = self
@@ -480,7 +480,7 @@ fn exposed_tools(
registry: &ExtensionRegistry<Config>,
session_store: &ExtensionData,
thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
registry
.tool_contributors()
.iter()
@@ -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))
}
}
+2 -3
View File
@@ -13,6 +13,7 @@ use codex_extension_api::PromptFragment;
use codex_extension_api::ThreadLifecycleContributor;
use codex_extension_api::ThreadStartInput;
use codex_extension_api::ToolContributor;
use codex_extension_api::ToolExecutor;
use codex_features::Feature;
use codex_otel::MetricsClient;
use codex_protocol::MemoryVersion;
@@ -139,9 +140,7 @@ impl ToolContributor for MemoriesExtension {
&self,
_session_store: &ExtensionData,
thread_store: &ExtensionData,
) -> Vec<
Arc<dyn for<'call> codex_extension_api::ToolExecutor<codex_extension_api::ToolCall<'call>>>,
> {
) -> Vec<Arc<dyn ToolExecutor>> {
let Some(config) = thread_store.get::<MemoriesExtensionConfig>() else {
return Vec::new();
};
+1 -4
View File
@@ -598,10 +598,7 @@ async fn search_tool_rejects_legacy_single_query() {
assert!(err.to_string().contains("query"));
}
fn memory_tool(
memory_root: &Path,
tool_name: &str,
) -> Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>> {
fn memory_tool(memory_root: &Path, tool_name: &str) -> Arc<dyn ToolExecutor> {
let expected_tool_name = memory_tool_name(tool_name);
crate::tools::memory_tools(
LocalMemoriesBackend::from_memory_root(memory_root),
@@ -41,7 +41,7 @@ pub(super) struct AddAdHocNoteTool<B> {
pub(super) metrics_client: Option<MetricsClient>,
}
impl<'call, B> ToolExecutor<ToolCall<'call>> for AddAdHocNoteTool<B>
impl<B> ToolExecutor for AddAdHocNoteTool<B>
where
B: MemoriesBackend,
{
@@ -56,10 +56,7 @@ where
)
}
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))
}
}
+2 -5
View File
@@ -39,7 +39,7 @@ pub(super) struct ListTool<B> {
pub(super) metrics_client: Option<MetricsClient>,
}
impl<'call, B> ToolExecutor<ToolCall<'call>> for ListTool<B>
impl<B> ToolExecutor for ListTool<B>
where
B: MemoriesBackend,
{
@@ -58,10 +58,7 @@ where
)
}
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))
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ mod search;
pub(crate) fn memory_tools<B>(
backend: B,
metrics_client: Option<MetricsClient>,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>>
) -> Vec<Arc<dyn ToolExecutor>>
where
B: MemoriesBackend,
{
+2 -5
View File
@@ -38,7 +38,7 @@ pub(super) struct ReadTool<B> {
pub(super) metrics_client: Option<MetricsClient>,
}
impl<'call, B> ToolExecutor<ToolCall<'call>> for ReadTool<B>
impl<B> ToolExecutor for ReadTool<B>
where
B: MemoriesBackend,
{
@@ -57,10 +57,7 @@ where
)
}
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))
}
}
+2 -5
View File
@@ -47,7 +47,7 @@ pub(super) struct SearchTool<B> {
pub(super) metrics_client: Option<MetricsClient>,
}
impl<'call, B> ToolExecutor<ToolCall<'call>> for SearchTool<B>
impl<B> ToolExecutor for SearchTool<B>
where
B: MemoriesBackend,
{
@@ -66,10 +66,7 @@ where
)
}
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))
}
}
@@ -4,7 +4,6 @@ use std::sync::Arc;
use codex_extension_api::ExtensionData;
use codex_extension_api::ExtensionRegistryBuilder;
use codex_extension_api::ToolCall;
use codex_extension_api::ToolContributor;
use codex_extension_api::ToolExecutor;
@@ -17,7 +16,7 @@ impl ToolContributor for FileCopyExtension {
&self,
_session_store: &ExtensionData,
_thread_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
vec![Arc::new(CopyFileTool)]
}
}
+2 -5
View File
@@ -39,7 +39,7 @@ impl CopyFileArgs {
}
}
impl<'call> ToolExecutor<ToolCall<'call>> for CopyFileTool {
impl ToolExecutor for CopyFileTool {
fn tool_name(&self) -> ToolName {
ToolName::plain(TOOL_NAME)
}
@@ -107,10 +107,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for CopyFileTool {
])
}
fn handle<'a>(&'a self, call: ToolCall<'call>) -> codex_tools::ToolExecutorFuture<'a>
where
'call: 'a,
{
fn handle<'a>(&'a self, call: ToolCall<'a>) -> codex_tools::ToolExecutorFuture<'a> {
Box::pin(async move {
let args = CopyFileArgs::parse(call.function_arguments()?)?;
let [source, target] = call.environments.as_slice() else {
+1 -2
View File
@@ -18,7 +18,6 @@ use codex_extension_api::PromptSlot;
use codex_extension_api::SkillInvocationContributor;
use codex_extension_api::ThreadLifecycleContributor;
use codex_extension_api::ThreadStartInput;
use codex_extension_api::ToolCall;
use codex_extension_api::ToolContributor;
use codex_extension_api::ToolExecutor;
use codex_extension_api::TurnInputContext;
@@ -282,7 +281,7 @@ where
session_store: &ExtensionData,
thread_store: &ExtensionData,
step_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
skill_tools(
self.providers.clone(),
session_store,
@@ -54,7 +54,7 @@ pub(super) struct InstallationsTool {
pub(super) metrics: Option<Arc<dyn ExtensionMetrics>>,
}
impl<'call> ToolExecutor<ToolCall<'call>> for InstallationsTool {
impl ToolExecutor for InstallationsTool {
fn tool_name(&self) -> ToolName {
skill_tool_name(TOOL_NAME)
}
@@ -70,10 +70,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for InstallationsTool {
)
}
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 mut outcome = "internal_error";
let mut source_filter = "unparsed";
+2 -5
View File
@@ -63,7 +63,7 @@ pub(super) struct ListTool {
pub(super) context: SkillToolContext,
}
impl<'call> ToolExecutor<ToolCall<'call>> for ListTool {
impl ToolExecutor for ListTool {
fn tool_name(&self) -> ToolName {
skill_tool_name(TOOL_NAME)
}
@@ -79,10 +79,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for ListTool {
)
}
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 args: ListArgs = parse_args(&call)?;
let response_byte_budget = call.response_byte_budget(MAX_SKILL_RESPONSE_BYTES);
+2 -2
View File
@@ -59,7 +59,7 @@ pub(crate) fn skill_tools(
session_store: &ExtensionData,
thread_store: &ExtensionData,
step_store: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
) -> Vec<Arc<dyn ToolExecutor>> {
let Some(thread_state) = thread_store.get::<SkillsThreadState>() else {
return Vec::new();
};
@@ -84,7 +84,7 @@ pub(crate) fn skill_tools(
analytics,
step_state,
};
let mut tools: Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> = vec![
let mut tools: Vec<Arc<dyn ToolExecutor>> = vec![
Arc::new(list::ListTool {
context: context.clone(),
}),
+2 -5
View File
@@ -90,7 +90,7 @@ pub(super) struct ReadTool {
pub(super) metrics: Option<Arc<dyn ExtensionMetrics>>,
}
impl<'call> ToolExecutor<ToolCall<'call>> for ReadTool {
impl ToolExecutor for ReadTool {
fn tool_name(&self) -> ToolName {
skill_tool_name(TOOL_NAME)
}
@@ -112,10 +112,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for ReadTool {
)
}
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 mut outcome = "internal_error";
let result = async {
@@ -133,10 +133,7 @@ impl MergeHarness {
Ok(harness)
}
async fn tools(
&self,
step: &ExtensionData,
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
async fn tools(&self, step: &ExtensionData) -> Vec<Arc<dyn ToolExecutor>> {
step.get_or_init(|| self.catalog_metrics.clone() as Arc<dyn ExtensionMetrics>);
if let Some(snapshots) = &self.snapshots {
step.insert(snapshots.clone());
@@ -220,7 +217,7 @@ impl MergeHarness {
}
pub(super) async fn call_tool(
tools: &[Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>],
tools: &[Arc<dyn ToolExecutor>],
name: &str,
arguments: Value,
) -> Result<Value, FunctionCallError> {
@@ -228,7 +225,7 @@ pub(super) async fn call_tool(
}
async fn call_tool_with_budget(
tools: &[Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>],
tools: &[Arc<dyn ToolExecutor>],
name: &str,
arguments: Value,
truncation_policy: TruncationPolicy,
+2 -3
View File
@@ -17,6 +17,7 @@ use codex_extension_api::ThreadLifecycleContributor;
use codex_extension_api::ThreadOriginator;
use codex_extension_api::ThreadStartInput;
use codex_extension_api::ToolContributor;
use codex_extension_api::ToolExecutor;
use codex_http_client::HttpClientFactory;
use codex_login::AuthManager;
use codex_model_provider::WorkspaceRoutingContext;
@@ -123,9 +124,7 @@ impl ToolContributor for WebSearchExtension {
session_store: &ExtensionData,
thread_store: &ExtensionData,
step_store: &ExtensionData,
) -> Vec<
Arc<dyn for<'call> codex_extension_api::ToolExecutor<codex_extension_api::ToolCall<'call>>>,
> {
) -> Vec<Arc<dyn ToolExecutor>> {
let (Some(config), Some(workspace_routing), Some(mode)) = (
thread_store.get::<WebSearchExtensionConfig>(),
thread_store.get::<WorkspaceRoutingContext>(),
+2 -5
View File
@@ -61,7 +61,7 @@ pub(crate) struct WebSearchTool {
pub(crate) originator: Option<String>,
}
impl<'call> ToolExecutor<ToolCall<'call>> for WebSearchTool {
impl ToolExecutor for WebSearchTool {
fn tool_name(&self) -> ToolName {
ToolName::namespaced(WEB_NAMESPACE, RUN_TOOL_NAME)
}
@@ -96,10 +96,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for WebSearchTool {
true
}
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))
}
}