mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
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:
@@ -39,7 +39,7 @@ use super::with_mcp_tool_call_ids_meta;
|
||||
pub async fn conversation_history_tools(
|
||||
parent: &Arc<CodexThread>,
|
||||
max_output_tokens: usize,
|
||||
) -> anyhow::Result<Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>>> {
|
||||
) -> anyhow::Result<Vec<Arc<dyn ToolExecutor>>> {
|
||||
let binding = history_binding(&parent.session).await?;
|
||||
let mut tools = Vec::new();
|
||||
for name in ["search_messages", "read_messages"] {
|
||||
@@ -63,8 +63,7 @@ pub async fn conversation_history_tools(
|
||||
parent: Arc::downgrade(&parent.session),
|
||||
function,
|
||||
max_output_tokens,
|
||||
})
|
||||
as Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>);
|
||||
}) as Arc<dyn ToolExecutor>);
|
||||
}
|
||||
Ok(tools)
|
||||
}
|
||||
@@ -93,7 +92,7 @@ struct HistoryTool {
|
||||
max_output_tokens: usize,
|
||||
}
|
||||
|
||||
impl<'call> ToolExecutor<ToolCall<'call>> for HistoryTool {
|
||||
impl ToolExecutor for HistoryTool {
|
||||
fn tool_name(&self) -> ToolName {
|
||||
ToolName::namespaced("user_message", &self.function.name)
|
||||
}
|
||||
@@ -114,10 +113,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for HistoryTool {
|
||||
ToolExposure::DirectModelOnly
|
||||
}
|
||||
|
||||
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 result: anyhow::Result<Box<dyn ToolOutput>> = async {
|
||||
let parent = self.parent.upgrade().context("Parent thread has stopped")?;
|
||||
|
||||
@@ -106,10 +106,7 @@ impl ToolExecutor<ToolInvocation> for TestHandler {
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async {
|
||||
Ok(Box::new(FunctionToolOutput::from_text(
|
||||
"audit-probe-ok".to_string(),
|
||||
|
||||
@@ -179,10 +179,7 @@ impl ToolExecutor<ToolInvocation> for CodeModeExecuteHandler {
|
||||
self.spec.clone()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,10 +59,7 @@ impl ToolExecutor<ToolInvocation> for CodeModeWaitHandler {
|
||||
self.spec.clone()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,10 @@ pub struct ToolInvocation {
|
||||
pub(crate) environments: ToolEnvironments,
|
||||
}
|
||||
|
||||
impl codex_tools::ToolInput for ToolInvocation {
|
||||
type Call<'a> = Self;
|
||||
}
|
||||
|
||||
/// Identity of the model call that started a tool invocation, retained across code-mode waits.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct ToolCallOrigin {
|
||||
|
||||
@@ -293,10 +293,7 @@ impl ToolExecutor<ToolInvocation> for ApplyPatchHandler {
|
||||
create_apply_patch_freeform_tool(self.multi_environment)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,10 +87,7 @@ impl ToolExecutor<ToolInvocation> for CurrentTimeHandler {
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
if !matches!(invocation.payload, ToolPayload::Function { .. }) {
|
||||
return Err(FunctionCallError::RespondToModel(format!(
|
||||
|
||||
@@ -120,10 +120,7 @@ impl ToolExecutor<ToolInvocation> for DynamicToolHandler {
|
||||
)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,10 @@ use crate::tools::registry::CoreToolRuntime;
|
||||
use crate::tools::registry::ToolExecutor;
|
||||
use crate::turn_metadata::ExecutionMetadata;
|
||||
|
||||
pub(crate) struct ExtensionToolAdapter(
|
||||
Arc<dyn for<'call> codex_tools::ToolExecutor<ExtensionToolCall<'call>>>,
|
||||
);
|
||||
pub(crate) struct ExtensionToolAdapter(Arc<dyn ToolExecutor>);
|
||||
|
||||
impl ExtensionToolAdapter {
|
||||
pub(crate) fn new(
|
||||
executor: Arc<dyn for<'call> codex_tools::ToolExecutor<ExtensionToolCall<'call>>>,
|
||||
) -> Self {
|
||||
pub(crate) fn new(executor: Arc<dyn ToolExecutor>) -> Self {
|
||||
Self(executor)
|
||||
}
|
||||
}
|
||||
@@ -60,10 +56,7 @@ impl ToolExecutor<ToolInvocation> for ExtensionToolAdapter {
|
||||
self.0.search_info()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let step = &invocation.step_context;
|
||||
let selected: Vec<_> = match &invocation.environments {
|
||||
@@ -296,9 +289,7 @@ mod tests {
|
||||
|
||||
struct StubExtensionExecutor;
|
||||
|
||||
impl<'call> codex_extension_api::ToolExecutor<codex_tools::ToolCall<'call>>
|
||||
for StubExtensionExecutor
|
||||
{
|
||||
impl codex_extension_api::ToolExecutor for StubExtensionExecutor {
|
||||
fn tool_name(&self) -> codex_tools::ToolName {
|
||||
codex_tools::ToolName::plain("extension_echo")
|
||||
}
|
||||
@@ -324,11 +315,8 @@ mod tests {
|
||||
|
||||
fn handle<'a>(
|
||||
&'a self,
|
||||
_call: codex_tools::ToolCall<'call>,
|
||||
) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
'call: 'a,
|
||||
{
|
||||
_call: codex_tools::ToolCall<'a>,
|
||||
) -> codex_tools::ToolExecutorFuture<'a> {
|
||||
Box::pin(async {
|
||||
Ok(
|
||||
Box::new(codex_tools::JsonToolOutput::new(json!({ "ok": true })))
|
||||
@@ -343,9 +331,7 @@ mod tests {
|
||||
captured_sandbox_cwds: Arc<Mutex<Vec<PathUri>>>,
|
||||
}
|
||||
|
||||
impl<'call> codex_extension_api::ToolExecutor<codex_tools::ToolCall<'call>>
|
||||
for CapturingExtensionExecutor
|
||||
{
|
||||
impl codex_extension_api::ToolExecutor for CapturingExtensionExecutor {
|
||||
fn tool_name(&self) -> codex_tools::ToolName {
|
||||
codex_tools::ToolName::plain("extension_echo")
|
||||
}
|
||||
@@ -363,11 +349,8 @@ mod tests {
|
||||
|
||||
fn handle<'a>(
|
||||
&'a self,
|
||||
call: codex_tools::ToolCall<'call>,
|
||||
) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
'call: 'a,
|
||||
{
|
||||
call: codex_tools::ToolCall<'a>,
|
||||
) -> codex_tools::ToolExecutorFuture<'a> {
|
||||
Box::pin(self.handle_call(call))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,10 +82,7 @@ impl ToolExecutor<ToolInvocation> for GetContextRemainingHandler {
|
||||
self.spec.clone()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
if !matches!(invocation.payload, ToolPayload::Function { .. }) {
|
||||
return Err(FunctionCallError::RespondToModel(
|
||||
|
||||
@@ -67,10 +67,7 @@ impl ToolExecutor<ToolInvocation> for ListAvailablePluginsToInstallHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,10 +235,7 @@ impl ToolExecutor<ToolInvocation> for McpHandler {
|
||||
)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,7 @@ impl ToolExecutor<ToolInvocation> for ListMcpResourceTemplatesHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,7 @@ impl ToolExecutor<ToolInvocation> for ListMcpResourcesHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +36,7 @@ impl ToolExecutor<ToolInvocation> for ReadMcpResourceHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move { handle_close_agent(invocation).await.map(boxed_tool_output) })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move { handle_resume_agent(invocation).await.map(boxed_tool_output) })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move { handle_spawn_agent(invocation).await.map(boxed_tool_output) })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,10 +44,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
create_followup_task_tool()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let mut analytics = ToolCallAnalytics::new(&invocation, CollabAgentTool::FollowupTask);
|
||||
let result = self.handle_call(invocation, &mut analytics).await;
|
||||
|
||||
@@ -17,10 +17,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
create_interrupt_agent_tool_v2()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let mut analytics =
|
||||
ToolCallAnalytics::new(&invocation, CollabAgentTool::InterruptAgent);
|
||||
|
||||
@@ -18,10 +18,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
create_list_agents_tool()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let analytics = ToolCallAnalytics::new(&invocation, CollabAgentTool::ListAgents);
|
||||
let result = self.handle_call(invocation).await;
|
||||
|
||||
@@ -17,10 +17,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
create_send_message_tool()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let mut analytics = ToolCallAnalytics::new(&invocation, CollabAgentTool::SendMessage);
|
||||
let result = self.handle_call(invocation, &mut analytics).await;
|
||||
|
||||
@@ -41,10 +41,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
create_spawn_agent_tool_v2(self.options.clone(), self.description_override.as_deref())
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let analytics = invocation.session.services.analytics_events_client.clone();
|
||||
let sender_thread_id = invocation.session.thread_id;
|
||||
|
||||
@@ -29,10 +29,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
|
||||
create_wait_agent_tool_v2(self.options)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,7 @@ impl ToolExecutor<ToolInvocation> for NewContextWindowHandler {
|
||||
self.spec.clone()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
if !matches!(invocation.payload, ToolPayload::Function { .. }) {
|
||||
return Err(FunctionCallError::RespondToModel(
|
||||
|
||||
@@ -55,10 +55,7 @@ impl ToolExecutor<ToolInvocation> for PlanHandler {
|
||||
create_update_plan_tool()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,10 +94,7 @@ impl ToolExecutor<ToolInvocation> for RequestPermissionsHandler {
|
||||
create_request_permissions_tool(request_permissions_tool_description())
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,7 @@ impl ToolExecutor<ToolInvocation> for RequestPluginInstallHandler {
|
||||
false
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,7 @@ impl ToolExecutor<ToolInvocation> for RequestUserInputHandler {
|
||||
create_request_user_input_tool(request_user_input_tool_description(&self.available_modes))
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +86,7 @@ impl ToolExecutor<ToolInvocation> for RequestUserInputAsyncHandler {
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -56,10 +56,7 @@ impl ToolExecutor<ToolInvocation> for SendMessageToUserAsyncHandler {
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -75,10 +75,7 @@ impl ToolExecutor<ToolInvocation> for SleepHandler {
|
||||
ToolExposure::DirectModelOnly
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let ToolInvocation {
|
||||
session,
|
||||
|
||||
@@ -73,10 +73,7 @@ impl ToolExecutor<ToolInvocation> for TestSyncHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,10 +212,7 @@ impl ToolExecutor<ToolInvocation> for ToolSearchHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,10 +120,7 @@ impl ToolExecutor<ToolInvocation> for ExecCommandHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,10 +57,7 @@ impl ToolExecutor<ToolInvocation> for WriteStdinHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +88,7 @@ impl ToolExecutor<ToolInvocation> for ViewImageHandler {
|
||||
true
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(self.handle_call(invocation))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +105,7 @@ impl ToolExecutor<ToolInvocation> for WaitForEnvironmentHandler {
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async move {
|
||||
let ToolInvocation {
|
||||
payload,
|
||||
|
||||
@@ -125,10 +125,7 @@ impl ToolExecutor<ToolInvocation> for MultiAgentV2ToolOverrides {
|
||||
self.handler.search_info()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
self.handler.handle(invocation)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1010,10 +1010,7 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
self.calls.fetch_add(1, Ordering::Relaxed);
|
||||
Box::pin(async {
|
||||
Ok(
|
||||
|
||||
@@ -22,10 +22,7 @@ impl ToolExecutor<ToolInvocation> for TestHandler {
|
||||
test_spec(&self.tool_name)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async {
|
||||
Ok(
|
||||
Box::new(crate::tools::context::FunctionToolOutput::from_text(
|
||||
@@ -53,10 +50,7 @@ impl ToolExecutor<ToolInvocation> for ReadinessTestHandler {
|
||||
self.handler.spec()
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
self.handler.handle(invocation)
|
||||
}
|
||||
}
|
||||
@@ -89,10 +83,7 @@ impl ToolExecutor<ToolInvocation> for LifecycleTestHandler {
|
||||
test_spec(&self.tool_name)
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
assert_eq!(
|
||||
invocation.tool_name,
|
||||
self.tool_name.clone().with_default_namespace()
|
||||
|
||||
@@ -116,14 +116,14 @@ impl codex_extension_api::ToolContributor for ExtensionEchoContributor {
|
||||
&self,
|
||||
_session_store: &ExtensionData,
|
||||
_thread_store: &ExtensionData,
|
||||
) -> Vec<Arc<dyn for<'call> ToolExecutor<ExtensionToolCall<'call>>>> {
|
||||
) -> Vec<Arc<dyn ToolExecutor>> {
|
||||
vec![Arc::new(ExtensionEchoExecutor)]
|
||||
}
|
||||
}
|
||||
|
||||
struct ExtensionEchoExecutor;
|
||||
|
||||
impl<'call> ToolExecutor<ExtensionToolCall<'call>> for ExtensionEchoExecutor {
|
||||
impl ToolExecutor for ExtensionEchoExecutor {
|
||||
fn tool_name(&self) -> ToolName {
|
||||
ToolName::namespaced("extension/", "echo")
|
||||
}
|
||||
@@ -151,10 +151,7 @@ impl<'call> ToolExecutor<ExtensionToolCall<'call>> for ExtensionEchoExecutor {
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, call: ExtensionToolCall<'call>) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
'call: 'a,
|
||||
{
|
||||
fn handle<'a>(&'a self, call: ExtensionToolCall<'a>) -> codex_tools::ToolExecutorFuture<'a> {
|
||||
Box::pin(self.handle_call(call))
|
||||
}
|
||||
}
|
||||
@@ -184,9 +181,7 @@ fn extension_tool_test_registry() -> Arc<ExtensionRegistry<Config>> {
|
||||
fn test_tool_router(
|
||||
step_context: &StepContext,
|
||||
mcp_tools: Vec<RegisteredTool>,
|
||||
extension_tool_executors: impl IntoIterator<
|
||||
Item = Arc<dyn for<'call> ToolExecutor<ExtensionToolCall<'call>>>,
|
||||
>,
|
||||
extension_tool_executors: impl IntoIterator<Item = Arc<dyn ToolExecutor>>,
|
||||
dynamic_tools: &[DynamicToolSpec],
|
||||
) -> ToolRouter {
|
||||
let mut registry = build_core_tool_registry(
|
||||
|
||||
@@ -84,7 +84,6 @@ use codex_protocol::protocol::MultiAgentVersion;
|
||||
use codex_tools::IndirectNamespacePrefixes;
|
||||
use codex_tools::ResponsesApiNamespaceTool;
|
||||
use codex_tools::TOOL_SEARCH_TOOL_NAME;
|
||||
use codex_tools::ToolCall as ExtensionToolCall;
|
||||
use codex_tools::ToolEnvironmentMode;
|
||||
use codex_tools::ToolExecutor;
|
||||
use codex_tools::ToolExposures;
|
||||
@@ -326,9 +325,7 @@ pub(crate) fn append_source_tools(
|
||||
model_info: &ModelInfo,
|
||||
registry: &mut ToolRegistry,
|
||||
mcp_tools: Vec<RegisteredTool>,
|
||||
extension_tool_executors: impl IntoIterator<
|
||||
Item = Arc<dyn for<'call> ToolExecutor<ExtensionToolCall<'call>>>,
|
||||
>,
|
||||
extension_tool_executors: impl IntoIterator<Item = Arc<dyn ToolExecutor>>,
|
||||
dynamic_tools: &[DynamicToolSpec],
|
||||
) -> Vec<ToolSpec> {
|
||||
for tool in mcp_tools {
|
||||
@@ -352,7 +349,7 @@ pub(crate) fn append_source_tools(
|
||||
pub(crate) fn extension_tool_executors<'a>(
|
||||
session: &'a Session,
|
||||
step_store: &'a ExtensionData,
|
||||
) -> impl Iterator<Item = Arc<dyn for<'call> ToolExecutor<ExtensionToolCall<'call>>>> + 'a {
|
||||
) -> impl Iterator<Item = Arc<dyn ToolExecutor>> + 'a {
|
||||
session
|
||||
.services
|
||||
.extensions
|
||||
@@ -1629,7 +1626,7 @@ fn append_tool_search_executor(
|
||||
fn append_extension_tool_executors(
|
||||
turn_context: &TurnContext,
|
||||
model_info: &ModelInfo,
|
||||
executors: impl IntoIterator<Item = Arc<dyn for<'call> ToolExecutor<ExtensionToolCall<'call>>>>,
|
||||
executors: impl IntoIterator<Item = Arc<dyn ToolExecutor>>,
|
||||
registry: &mut ToolRegistry,
|
||||
) -> Option<ToolName> {
|
||||
let standalone_web_search_enabled = standalone_web_search_enabled(turn_context, model_info);
|
||||
|
||||
@@ -205,7 +205,7 @@ async fn strict_finalization_cannot_resurrect_hidden_or_policy_denied_tools() {
|
||||
),
|
||||
mcp_runtime("denied", "mcp__denied", "lookup", ToolExposure::Direct),
|
||||
],
|
||||
std::iter::empty::<Arc<dyn for<'call> ToolExecutor<ExtensionToolCall<'call>>>>(),
|
||||
std::iter::empty::<Arc<dyn ToolExecutor>>(),
|
||||
&[
|
||||
dynamic_tool(
|
||||
/*namespace*/ None,
|
||||
|
||||
@@ -69,7 +69,7 @@ const MULTI_AGENT_V2_NAMESPACE: &str = "collaboration";
|
||||
struct ToolPlanInputs {
|
||||
tool_runtimes: Vec<RegisteredTool>,
|
||||
tool_suggest_candidates: Option<ToolSuggestCandidates>,
|
||||
extension_tool_executors: Vec<Arc<dyn for<'call> ToolExecutor<ExtensionToolCall<'call>>>>,
|
||||
extension_tool_executors: Vec<Arc<dyn ToolExecutor>>,
|
||||
wait_for_environment_tool_config: Option<Arc<WaitForEnvironmentToolConfig>>,
|
||||
dynamic_tools: Vec<DynamicToolSpec>,
|
||||
}
|
||||
@@ -317,7 +317,7 @@ struct TestNamespaceExtensionTool {
|
||||
tool_name: &'static str,
|
||||
}
|
||||
|
||||
impl<'call> ToolExecutor<ExtensionToolCall<'call>> for TestNamespaceExtensionTool {
|
||||
impl ToolExecutor for TestNamespaceExtensionTool {
|
||||
fn tool_name(&self) -> ToolName {
|
||||
ToolName::namespaced(self.namespace, self.tool_name)
|
||||
}
|
||||
@@ -337,10 +337,7 @@ impl<'call> ToolExecutor<ExtensionToolCall<'call>> for TestNamespaceExtensionToo
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, _call: ExtensionToolCall<'call>) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
'call: 'a,
|
||||
{
|
||||
fn handle<'a>(&'a self, _call: ExtensionToolCall<'a>) -> codex_tools::ToolExecutorFuture<'a> {
|
||||
Box::pin(async {
|
||||
Ok(Box::new(codex_tools::JsonToolOutput::new(json!({}))) as Box<dyn ToolOutput>)
|
||||
})
|
||||
@@ -349,7 +346,7 @@ impl<'call> ToolExecutor<ExtensionToolCall<'call>> for TestNamespaceExtensionToo
|
||||
|
||||
struct DeferredExtensionTool;
|
||||
|
||||
impl<'call> ToolExecutor<ExtensionToolCall<'call>> for DeferredExtensionTool {
|
||||
impl ToolExecutor for DeferredExtensionTool {
|
||||
fn tool_name(&self) -> ToolName {
|
||||
ToolName::plain("extension_echo")
|
||||
}
|
||||
@@ -376,10 +373,7 @@ impl<'call> ToolExecutor<ExtensionToolCall<'call>> for DeferredExtensionTool {
|
||||
ToolExposure::Deferred
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, _call: ExtensionToolCall<'call>) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
'call: 'a,
|
||||
{
|
||||
fn handle<'a>(&'a self, _call: ExtensionToolCall<'a>) -> codex_tools::ToolExecutorFuture<'a> {
|
||||
Box::pin(async { panic!("spec planning should not execute extension tools") })
|
||||
}
|
||||
}
|
||||
@@ -536,10 +530,7 @@ async fn allowed_tools_filter_sources_before_code_mode_and_discovery() {
|
||||
mcp_runtime("kept", "kept", "lookup", ToolExposure::Deferred),
|
||||
mcp_runtime("excluded", "excluded", "lookup", ToolExposure::Deferred),
|
||||
],
|
||||
[Arc::new(DeferredExtensionTool)
|
||||
as Arc<
|
||||
dyn for<'call> ToolExecutor<ExtensionToolCall<'call>>,
|
||||
>],
|
||||
[Arc::new(DeferredExtensionTool) as Arc<dyn ToolExecutor>],
|
||||
&[dynamic_tool(
|
||||
/*namespace*/ None,
|
||||
"dynamic_echo",
|
||||
|
||||
@@ -48,10 +48,7 @@ impl ToolExecutor<ToolInvocation> for TestHandler {
|
||||
})
|
||||
}
|
||||
|
||||
fn handle<'a>(&'a self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
|
||||
where
|
||||
ToolInvocation: 'a,
|
||||
{
|
||||
fn handle(&self, _invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
|
||||
Box::pin(async {
|
||||
Ok(
|
||||
Box::new(FunctionToolOutput::from_text("ok".to_string(), Some(true)))
|
||||
|
||||
@@ -8,7 +8,6 @@ use codex_protocol::dynamic_tools::DynamicToolFunctionSpec;
|
||||
use codex_protocol::dynamic_tools::DynamicToolSpec;
|
||||
use codex_protocol::request_user_input::RequestUserInputAnswer;
|
||||
use codex_protocol::request_user_input::RequestUserInputResponse;
|
||||
use codex_tools::ToolCall;
|
||||
use codex_tools::ToolExecutor;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::collections::HashMap;
|
||||
@@ -42,7 +41,7 @@ impl ToolContributor for StepPreparationObserver {
|
||||
&self,
|
||||
_session_store: &ExtensionData,
|
||||
_thread_store: &ExtensionData,
|
||||
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
|
||||
) -> Vec<Arc<dyn ToolExecutor>> {
|
||||
if let Some(ready) = self.tools_ready.lock().expect("tool gate").take() {
|
||||
ready
|
||||
.send(())
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -63,12 +63,12 @@ impl ToolContributor for GatedTool {
|
||||
&self,
|
||||
_session_store: &ExtensionData,
|
||||
_thread_store: &ExtensionData,
|
||||
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
|
||||
) -> Vec<Arc<dyn ToolExecutor>> {
|
||||
vec![Arc::new(self.clone())]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'call> ToolExecutor<ToolCall<'call>> for GatedTool {
|
||||
impl ToolExecutor for GatedTool {
|
||||
fn tool_name(&self) -> ToolName {
|
||||
ToolName::plain(if matches!(self.admission, Admission::Unsupported) {
|
||||
"followup_task"
|
||||
@@ -92,10 +92,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for GatedTool {
|
||||
matches!(self.admission, Admission::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 {
|
||||
self.entered
|
||||
.send((call.call_id.to_string(), Instant::now()))
|
||||
|
||||
@@ -953,12 +953,12 @@ impl ToolContributor for DeferredCustomTool {
|
||||
&self,
|
||||
_session_store: &ExtensionData,
|
||||
_thread_store: &ExtensionData,
|
||||
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
|
||||
) -> Vec<Arc<dyn ToolExecutor>> {
|
||||
vec![Arc::new(Self)]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'call> ToolExecutor<ToolCall<'call>> for DeferredCustomTool {
|
||||
impl ToolExecutor for DeferredCustomTool {
|
||||
fn tool_name(&self) -> ToolName {
|
||||
ToolName::plain("custom_echo")
|
||||
}
|
||||
@@ -980,10 +980,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for DeferredCustomTool {
|
||||
ToolExposure::Deferred
|
||||
}
|
||||
|
||||
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(
|
||||
|
||||
@@ -187,7 +187,6 @@ async fn step_preparation_finishes_before_tools_and_world_state() -> Result<()>
|
||||
use codex_extension_api::ExtensionFuture;
|
||||
use codex_extension_api::SelectedPluginSnapshot;
|
||||
use codex_extension_api::StepPreparationInput;
|
||||
use codex_extension_api::ToolCall;
|
||||
use codex_extension_api::ToolContributor;
|
||||
use codex_extension_api::ToolExecutor;
|
||||
use codex_extension_api::WorldStateContributionInput;
|
||||
@@ -221,7 +220,7 @@ async fn step_preparation_finishes_before_tools_and_world_state() -> Result<()>
|
||||
_session_store: &ExtensionData,
|
||||
_thread_store: &ExtensionData,
|
||||
step_store: &ExtensionData,
|
||||
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
|
||||
) -> Vec<Arc<dyn ToolExecutor>> {
|
||||
assert!(step_store.get::<SelectedPluginSnapshot>().is_some());
|
||||
assert_eq!(
|
||||
*step_store
|
||||
|
||||
@@ -2998,12 +2998,12 @@ impl ToolContributor for SettingsEcho {
|
||||
&self,
|
||||
_session_store: &ExtensionData,
|
||||
_thread_store: &ExtensionData,
|
||||
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
|
||||
) -> Vec<Arc<dyn ToolExecutor>> {
|
||||
vec![Arc::new(self.clone())]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'call> ToolExecutor<ToolCall<'call>> for SettingsEcho {
|
||||
impl ToolExecutor for SettingsEcho {
|
||||
fn tool_name(&self) -> ToolName {
|
||||
ToolName::plain("extension_settings")
|
||||
}
|
||||
@@ -3019,10 +3019,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for SettingsEcho {
|
||||
})
|
||||
}
|
||||
|
||||
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 {
|
||||
*self.history.lock().expect("history lock") = Some(call.conversation_history);
|
||||
let metadata: Value = serde_json::from_str(
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(),
|
||||
}),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>(),
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ use uuid::Uuid;
|
||||
/// The board's host continues to handle notifications; this service adds no
|
||||
/// Core delivery, lifecycle registration, or MCP push notifications.
|
||||
pub struct MessageBoardMcpServer {
|
||||
tools: Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>>,
|
||||
tools: Vec<Arc<dyn ToolExecutor>>,
|
||||
invocation_scope: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ pub fn message_board_tools(
|
||||
namespace: Option<&str>,
|
||||
namespace_description: &str,
|
||||
tool_messages: Option<&MultiAgentToolMessages>,
|
||||
) -> Vec<Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>> {
|
||||
) -> Vec<Arc<dyn ToolExecutor>> {
|
||||
tools
|
||||
.iter()
|
||||
.map(|&tool| {
|
||||
@@ -78,7 +78,7 @@ pub fn message_board_tools(
|
||||
namespace: namespace.map(str::to_owned),
|
||||
namespace_description: namespace_description.to_owned(),
|
||||
description: tool_message.and_then(|tool| tool.description.clone()),
|
||||
}) as Arc<dyn for<'call> ToolExecutor<ToolCall<'call>>>
|
||||
}) as Arc<dyn ToolExecutor>
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -93,7 +93,7 @@ struct BoardTool {
|
||||
description: Option<CodexCachedStr>,
|
||||
}
|
||||
|
||||
impl<'call> ToolExecutor<ToolCall<'call>> for BoardTool {
|
||||
impl ToolExecutor for BoardTool {
|
||||
fn tool_name(&self) -> ToolName {
|
||||
ToolName::new(self.namespace.clone(), self.tool.name())
|
||||
}
|
||||
@@ -109,10 +109,7 @@ impl<'call> ToolExecutor<ToolCall<'call>> for BoardTool {
|
||||
MessageBoardTool::READ_ONLY.contains(&self.tool)
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -98,10 +98,12 @@ pub use tool_discovery::TOOL_SEARCH_TOOL_NAME;
|
||||
pub use tool_discovery::ToolSearchSourceInfo;
|
||||
pub use tool_discovery::collect_request_plugin_install_entries;
|
||||
pub use tool_discovery::filter_request_plugin_install_discoverable_tools_for_client;
|
||||
pub use tool_executor::BorrowedToolCall;
|
||||
pub use tool_executor::ToolExecutor;
|
||||
pub use tool_executor::ToolExecutorFuture;
|
||||
pub use tool_executor::ToolExposure;
|
||||
pub use tool_executor::ToolExposures;
|
||||
pub use tool_executor::ToolInput;
|
||||
pub use tool_output::JsonToolOutput;
|
||||
pub use tool_output::ToolOutput;
|
||||
pub use tool_payload::ToolPayload;
|
||||
|
||||
@@ -98,12 +98,25 @@ impl ToolExposure {
|
||||
}
|
||||
}
|
||||
|
||||
/// Selects the input a tool receives for the lifetime of one call.
|
||||
/// Keeping the associated type here lets `ToolExecutor` remain dyn-compatible.
|
||||
pub trait ToolInput {
|
||||
type Call<'a>: 'a;
|
||||
}
|
||||
|
||||
/// Extension tools borrow host capabilities for the duration of the call.
|
||||
pub enum BorrowedToolCall {}
|
||||
|
||||
impl ToolInput for BorrowedToolCall {
|
||||
type Call<'a> = crate::ToolCall<'a>;
|
||||
}
|
||||
|
||||
/// Shared runtime contract for model-visible tools.
|
||||
///
|
||||
/// Implementations keep the model-visible spec tied to the executable runtime.
|
||||
/// Host crates can layer routing, hooks, telemetry, or other orchestration on
|
||||
/// top without reopening the spec/runtime split.
|
||||
pub trait ToolExecutor<Invocation>: Send + Sync {
|
||||
pub trait ToolExecutor<Input: ToolInput = BorrowedToolCall>: Send + Sync {
|
||||
/// The concrete tool name handled by this runtime instance.
|
||||
fn tool_name(&self) -> ToolName;
|
||||
|
||||
@@ -133,7 +146,5 @@ pub trait ToolExecutor<Invocation>: Send + Sync {
|
||||
}
|
||||
|
||||
/// Handles one invocation without retaining capabilities borrowed by the host.
|
||||
fn handle<'a>(&'a self, invocation: Invocation) -> ToolExecutorFuture<'a>
|
||||
where
|
||||
Invocation: 'a;
|
||||
fn handle<'a>(&'a self, invocation: Input::Call<'a>) -> ToolExecutorFuture<'a>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user