pub struct ThreadManager { /* private fields */ }Expand description
ThreadManager is responsible for creating threads and maintaining
them in memory.
Implementations§
Source§impl ThreadManager
impl ThreadManager
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
pub fn session_source(&self) -> SessionSource
pub fn auth_manager(&self) -> Arc<AuthManager> ⓘ
pub fn skills_service(&self) -> Arc<SkillsService> ⓘ
pub fn plugins_manager(&self) -> Arc<PluginsManager> ⓘ
pub fn mcp_manager(&self) -> Arc<McpManager> ⓘ
pub fn environment_manager(&self) -> Arc<EnvironmentManager> ⓘ
pub fn default_environment_selections( &self, cwd: &AbsolutePathBuf, workspace_roots: &[AbsolutePathBuf], ) -> Vec<TurnEnvironmentSelection>
pub fn validate_environment_selections( &self, environments: &[TurnEnvironmentSelection], ) -> CodexResult<()>
pub fn get_models_manager(&self) -> SharedModelsManager
pub async fn list_models( &self, refresh_strategy: RefreshStrategy, http_client_factory: HttpClientFactory, ) -> Vec<ModelPreset>
pub fn list_collaboration_modes(&self) -> Vec<CollaborationModeMask>
pub async fn list_thread_ids(&self) -> Vec<ThreadId>
pub fn subscribe_thread_created(&self) -> Receiver<ThreadId>
pub async fn get_thread( &self, thread_id: ThreadId, ) -> CodexResult<Arc<CodexThread>>
Sourcepub async fn update_thread_metadata(
&self,
thread_id: ThreadId,
patch: ThreadMetadataPatch,
include_archived: bool,
) -> CodexResult<StoredThread>
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.
Sourcepub async fn list_agent_subtree_thread_ids(
&self,
thread_id: ThreadId,
) -> CodexResult<Vec<ThreadId>>
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.
pub async fn start_thread(&self, config: Config) -> CodexResult<NewThread>
pub async fn start_thread_with_tools( &self, config: Config, dynamic_tools: Vec<DynamicToolSpec>, ) -> CodexResult<NewThread>
pub async fn start_thread_with_options( &self, options: StartThreadOptions, ) -> CodexResult<NewThread>
Sourcepub async fn spawn_subagent(
&self,
forked_from_thread_id: ThreadId,
options: StartThreadOptions,
) -> CodexResult<NewThread>
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.
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>
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>
Sourcepub async fn remove_thread(
&self,
thread_id: &ThreadId,
) -> Option<Arc<CodexThread>>
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.
Sourcepub async fn shutdown_all_threads_bounded(
&self,
timeout: Duration,
) -> ThreadShutdownReport
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.
Sourcepub 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>,
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.
Sourcepub 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>,
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§
impl !RefUnwindSafe for ThreadManager
impl !UnwindSafe for ThreadManager
impl Freeze for ThreadManager
impl Send for ThreadManager
impl Sync for ThreadManager
impl Unpin for ThreadManager
impl UnsafeUnpin for ThreadManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<T> AsTypeStaticRegistered for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
impl<T> HasTyVTable for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request