mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
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:
1 parent
eed1dee69e
commit
81e180044d
85 files changed
+477
-202
No files matched your search
@@ -9,6 +9,7 @@ use codex_protocol::protocol::EventMsg;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_output_truncation::TruncationPolicy;
|
||||
use std::future::Future;
|
||||
use std::marker::PhantomData;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -61,7 +62,7 @@ pub trait TurnItemEmitter: Send + Sync {
|
||||
|
||||
/// Host-owned turn environment summary visible to extension tools.
|
||||
#[derive(Clone)]
|
||||
pub struct ToolEnvironment {
|
||||
pub struct ToolEnvironment<'call> {
|
||||
/// Stable host environment id used to route executor-scoped capabilities.
|
||||
pub environment_id: String,
|
||||
/// Effective working directory for this turn in the environment.
|
||||
@@ -70,6 +71,8 @@ pub struct ToolEnvironment {
|
||||
pub file_system: Arc<dyn ExecutorFileSystem>,
|
||||
/// Sandbox context to use for filesystem operations.
|
||||
pub file_system_sandbox_context: FileSystemSandboxContext,
|
||||
// TODO(anp): Replace the marker with callback-scoped environment access.
|
||||
pub _lifetime: PhantomData<&'call ()>,
|
||||
}
|
||||
|
||||
/// Turn-item emitter used when a caller does not expose visible item emission.
|
||||
@@ -101,7 +104,7 @@ pub enum ToolCallSource {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ToolCall {
|
||||
pub struct ToolCall<'call> {
|
||||
pub turn_id: String,
|
||||
pub call_id: String,
|
||||
pub tool_name: ToolName,
|
||||
@@ -111,11 +114,11 @@ pub struct ToolCall {
|
||||
pub source: ToolCallSource,
|
||||
pub conversation_history: ConversationHistory,
|
||||
pub turn_item_emitter: Arc<dyn TurnItemEmitter>,
|
||||
pub environments: Vec<ToolEnvironment>,
|
||||
pub environments: Vec<ToolEnvironment<'call>>,
|
||||
pub payload: ToolPayload,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for ToolCall {
|
||||
impl std::fmt::Debug for ToolCall<'_> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("ToolCall")
|
||||
.field("turn_id", &self.turn_id)
|
||||
@@ -136,7 +139,7 @@ impl std::fmt::Debug for ToolCall {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolCall {
|
||||
impl ToolCall<'_> {
|
||||
/// Returns the response-content budget, bounded by the tool's own size limit.
|
||||
///
|
||||
/// Direct calls use the host's effective text-output allowance. Code Mode receives
|
||||
|
||||
Reference in new issue
Block a user