Scope extension capabilities to invocation lifetimes (#41020)

## What changed

- Add callback lifetimes to extension `ToolCall`, `ToolEnvironment`, turn-input context, and skill-read request types.
- Require extension tool executors to handle calls for any invocation lifetime and tie their returned futures to that lifetime.
- Update built-in extensions, adapters, and tests to use the lifetime-scoped APIs without retaining host-owned environment capabilities.

GitOrigin-RevId: aca9ce3a1b6870df550bc84ec9308cc65533f161
This commit is contained in:
Adam Perry @ OpenAI authored and copyberry committed 2026-08-27 02:00:31 +00:00
1 parent eed1dee69e
commit 81e180044d
85 files changed
+477 -202

No files matched your search

+3 -1
View File
@@ -415,7 +415,9 @@ where
&self,
_session_store: &ExtensionData,
thread_store: &ExtensionData,
) -> Vec<Arc<dyn codex_extension_api::ToolExecutor<codex_extension_api::ToolCall>>> {
) -> Vec<
Arc<dyn for<'call> codex_extension_api::ToolExecutor<codex_extension_api::ToolCall<'call>>>,
> {
let Some(runtime) = goal_runtime_handle(thread_store) else {
return Vec::new();
};
+12 -6
View File
@@ -136,7 +136,7 @@ impl GoalToolExecutor {
}
}
impl ToolExecutor<ToolCall> for GoalToolExecutor {
impl<'call> ToolExecutor<ToolCall<'call>> for GoalToolExecutor {
fn tool_name(&self) -> ToolName {
ToolName::plain(match self.kind {
GoalToolKind::Get => GET_GOAL_TOOL_NAME,
@@ -153,7 +153,13 @@ impl ToolExecutor<ToolCall> for GoalToolExecutor {
}
}
fn handle(&self, invocation: ToolCall) -> codex_extension_api::ToolExecutorFuture<'_> {
fn handle<'a>(
&'a self,
invocation: ToolCall<'call>,
) -> codex_extension_api::ToolExecutorFuture<'a>
where
'call: 'a,
{
Box::pin(async move {
match self.kind {
GoalToolKind::Get => self.handle_get(invocation).await,
@@ -167,7 +173,7 @@ impl ToolExecutor<ToolCall> for GoalToolExecutor {
impl GoalToolExecutor {
async fn handle_get(
&self,
invocation: ToolCall,
invocation: ToolCall<'_>,
) -> Result<Box<dyn ToolOutput>, FunctionCallError> {
let _ = invocation.function_arguments()?;
let goal = self
@@ -184,7 +190,7 @@ impl GoalToolExecutor {
async fn handle_create(
&self,
invocation: ToolCall,
invocation: ToolCall<'_>,
) -> Result<Box<dyn ToolOutput>, FunctionCallError> {
let mut request: CreateGoalRequest = parse_arguments(invocation.function_arguments()?)?;
request.objective = request.objective.trim().to_string();
@@ -227,7 +233,7 @@ impl GoalToolExecutor {
async fn handle_update(
&self,
invocation: ToolCall,
invocation: ToolCall<'_>,
) -> Result<Box<dyn ToolOutput>, FunctionCallError> {
let args: UpdateGoalArgs = parse_arguments(invocation.function_arguments()?)?;
if !matches!(
@@ -299,7 +305,7 @@ impl GoalToolExecutor {
fn emit_goal_updated_from_tool_call(
&self,
invocation: &ToolCall,
invocation: &ToolCall<'_>,
turn_id: Option<String>,
goal: ThreadGoal,
) {