Skip to main content

ThreadManager

Struct ThreadManager 

Source
pub struct ThreadManager { /* private fields */ }
Expand description

ThreadManager is responsible for creating threads and maintaining them in memory.

Implementations§

Source§

impl ThreadManager

Source

pub fn new( config: &Config, auth_manager: Arc<AuthManager>, models_manager: SharedModelsManager, codex_apps_tools_cache: CodexAppsToolsCache, session_source: SessionSource, environment_manager: Arc<EnvironmentManager>, extensions: Arc<ExtensionRegistry<Config>>, user_instructions_provider: Arc<dyn UserInstructionsProvider>, analytics_events_client: Option<AnalyticsEventsClient>, thread_store: Arc<dyn ThreadStore>, agent_graph_store: Option<Arc<dyn AgentGraphStore>>, installation_id: String, attestation_provider: Option<Arc<dyn AttestationProvider>>, external_time_provider: Option<Arc<dyn TimeProvider>>, ) -> Self

Source

pub fn session_source(&self) -> SessionSource

Source

pub fn auth_manager(&self) -> Arc<AuthManager>

Source

pub fn skills_service(&self) -> Arc<SkillsService>

Source

pub fn plugins_manager(&self) -> Arc<PluginsManager>

Source

pub fn mcp_manager(&self) -> Arc<McpManager>

Source

pub fn environment_manager(&self) -> Arc<EnvironmentManager>

Source

pub fn default_environment_selections( &self, cwd: &AbsolutePathBuf, workspace_roots: &[AbsolutePathBuf], ) -> Vec<TurnEnvironmentSelection>

Source

pub fn validate_environment_selections( &self, environments: &[TurnEnvironmentSelection], ) -> CodexResult<()>

Source

pub fn get_models_manager(&self) -> SharedModelsManager

Source

pub async fn list_models( &self, refresh_strategy: RefreshStrategy, http_client_factory: HttpClientFactory, ) -> Vec<ModelPreset>

Source

pub fn list_collaboration_modes(&self) -> Vec<CollaborationModeMask>

Source

pub async fn list_thread_ids(&self) -> Vec<ThreadId>

Source

pub fn subscribe_thread_created(&self) -> Receiver<ThreadId>

Source

pub async fn get_thread( &self, thread_id: ThreadId, ) -> CodexResult<Arc<CodexThread>>

Source

pub async fn update_thread_metadata( &self, thread_id: ThreadId, patch: ThreadMetadataPatch, include_archived: bool, ) -> CodexResult<StoredThread>

Updates metadata for loaded and cold threads through one entrypoint.

Loaded threads route through CodexThread/LiveThread, so metadata changes stay ordered with live rollout writes. Cold threads go directly to the store, which owns unloaded JSONL compatibility and SQLite metadata updates.

Source

pub async fn list_agent_subtree_thread_ids( &self, thread_id: ThreadId, ) -> CodexResult<Vec<ThreadId>>

List thread_id plus all known descendants in its spawn subtree.

Source

pub async fn start_thread(&self, config: Config) -> CodexResult<NewThread>

Source

pub async fn start_thread_with_tools( &self, config: Config, dynamic_tools: Vec<DynamicToolSpec>, ) -> CodexResult<NewThread>

Source

pub async fn start_thread_with_options( &self, options: StartThreadOptions, ) -> CodexResult<NewThread>

Source

pub async fn spawn_subagent( &self, forked_from_thread_id: ThreadId, options: StartThreadOptions, ) -> CodexResult<NewThread>

Spawn a subagent by forking persisted history from forked_from_thread_id.

Source

pub async fn resume_thread_from_rollout( &self, config: Config, rollout_path: PathBuf, auth_manager: Arc<AuthManager>, parent_trace: Option<W3cTraceContext>, supports_openai_form_elicitation: bool, ) -> CodexResult<NewThread>

Source

pub async fn resume_thread_with_history( &self, config: Config, initial_history: InitialHistory, auth_manager: Arc<AuthManager>, parent_trace: Option<W3cTraceContext>, supports_openai_form_elicitation: bool, ) -> CodexResult<NewThread>

Source

pub async fn remove_thread( &self, thread_id: &ThreadId, ) -> Option<Arc<CodexThread>>

Removes the thread from the manager’s internal map, though the thread is stored as Arc<CodexThread>, it is possible that other references to it exist elsewhere. Returns the thread if the thread was found and removed.

Source

pub async fn shutdown_all_threads_bounded( &self, timeout: Duration, ) -> ThreadShutdownReport

Tries to shut down all tracked threads concurrently within the provided timeout. Threads that complete shutdown are removed from the manager; incomplete shutdowns remain tracked so callers can retry or inspect them later.

Source

pub async fn fork_thread<S>( &self, snapshot: S, config: Config, path: PathBuf, thread_source: Option<ThreadSource>, parent_trace: Option<W3cTraceContext>, ) -> CodexResult<NewThread>
where S: Into<ForkSnapshot>,

Fork an existing thread by snapshotting rollout history according to snapshot and starting a new thread with identical configuration (unless overridden by the caller’s config). The new thread will have a fresh id.

Source

pub async fn fork_thread_from_history<S>( &self, snapshot: S, config: Config, history: InitialHistory, thread_source: Option<ThreadSource>, parent_trace: Option<W3cTraceContext>, supports_openai_form_elicitation: bool, ) -> CodexResult<NewThread>
where S: Into<ForkSnapshot>,

Fork an existing thread from already-loaded store history.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> AsTypeStaticRegistered for T

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> HasTyVTable for T
where T: ?Sized,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> RamaFrom<T> for U
where U: From<T>,

Source§

fn rama_from(value: T) -> U

Source§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

Source§

fn rama_into(self) -> U

Source§

impl<T, U> RamaTryFrom<T> for U
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

Source§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

Source§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

Source§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

Source§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more