pub struct CodexThread { /* private fields */ }Implementations§
Source§impl CodexThread
Conduit for the bidirectional stream of messages that compose a thread
(formerly called a conversation) in Codex.
impl CodexThread
Conduit for the bidirectional stream of messages that compose a thread (formerly called a conversation) in Codex.
pub async fn submit(&self, op: Op) -> CodexResult<String>
Sourcepub fn session_telemetry(&self) -> SessionTelemetry
pub fn session_telemetry(&self) -> SessionTelemetry
Returns the session telemetry handle for thread-scoped production instrumentation.
pub async fn shutdown_and_wait(&self) -> CodexResult<()>
Sourcepub async fn wait_until_terminated(&self)
pub async fn wait_until_terminated(&self)
Wait until the underlying session loop has terminated.
pub async fn emit_thread_idle_lifecycle_if_idle(&self)
pub async fn submit_with_trace( &self, op: Op, trace: Option<W3cTraceContext>, ) -> CodexResult<String>
pub async fn submit_user_input_with_client_user_message_id( &self, op: Op, trace: Option<W3cTraceContext>, client_user_message_id: Option<String>, ) -> CodexResult<String>
Sourcepub async fn set_thread_memory_mode(&self, mode: ThreadMemoryMode) -> Result<()>
pub async fn set_thread_memory_mode(&self, mode: ThreadMemoryMode) -> Result<()>
Persist whether this thread is eligible for future memory generation.
pub async fn steer_input( &self, input: Vec<UserInput>, additional_context: BTreeMap<String, AdditionalContextEntry>, expected_turn_id: Option<&str>, client_user_message_id: Option<String>, responsesapi_client_metadata: Option<HashMap<String, String>>, ) -> Result<String, SteerInputError>
Sourcepub async fn inject_if_running(
&self,
items: Vec<ResponseItem>,
) -> Result<(), Vec<ResponseItem>>
pub async fn inject_if_running( &self, items: Vec<ResponseItem>, ) -> Result<(), Vec<ResponseItem>>
Injects model-visible items into the currently active turn.
This is the thread-level bridge to Session::inject_if_running for
callers that only hold a CodexThread.
It returns the unchanged items when this thread has no active turn.
Sourcepub async fn try_start_turn_if_idle(
&self,
items: Vec<ResponseItem>,
) -> Result<(), TryStartTurnIfIdleError>
pub async fn try_start_turn_if_idle( &self, items: Vec<ResponseItem>, ) -> Result<(), TryStartTurnIfIdleError>
Starts an automatic regular turn with model-visible items only when idle work is allowed for this thread.
This is the required entry point for extensions that want to launch
model-visible work from ThreadLifecycleContributor::on_thread_idle.
The call succeeds only if no user/client-triggered turn is queued, no
task is currently active, and the thread is not in Plan mode. Active
Review tasks are rejected by the active-task check because Review turns
are not steerable.
On rejection, the returned error includes a stable reason and carries
the original items unchanged so the caller can decide whether to drop
them, retry later, or log why no automatic turn was started.
pub async fn set_app_server_client_info( &self, app_server_client_name: Option<String>, app_server_client_version: Option<String>, mcp_elicitations_auto_deny: bool, ) -> ConstraintResult<()>
pub async fn set_openai_form_elicitation_support( &self, supported: bool, ) -> Result<()>
Sourcepub async fn preview_thread_settings_overrides(
&self,
overrides: CodexThreadSettingsOverrides,
) -> ConstraintResult<ThreadConfigSnapshot>
pub async fn preview_thread_settings_overrides( &self, overrides: CodexThreadSettingsOverrides, ) -> ConstraintResult<ThreadConfigSnapshot>
Preview persistent thread settings overrides without committing them.
Sourcepub async fn submit_with_id(&self, sub: Submission) -> CodexResult<()>
pub async fn submit_with_id(&self, sub: Submission) -> CodexResult<()>
Use sparingly: this is intended to be removed soon.
pub async fn next_event(&self) -> CodexResult<Event>
pub async fn agent_status(&self) -> AgentStatus
pub async fn list_background_terminals(&self) -> Vec<BackgroundTerminalInfo>
pub async fn terminate_background_terminal(&self, process_id: i32) -> bool
Sourcepub async fn token_usage_info(&self) -> Option<TokenUsageInfo>
pub async fn token_usage_info(&self) -> Option<TokenUsageInfo>
Returns the complete token usage snapshot currently cached for this thread.
This accessor is intentionally narrower than direct session access: it lets
app-server lifecycle paths replay restored usage after resume or fork without
exposing broader session mutation authority. A caller that only reads
total_token_usage would drop last-turn usage and make the v2
thread/tokenUsage/updated payload incomplete.
Sourcepub async fn inject_response_items(
&self,
items: Vec<ResponseItem>,
) -> CodexResult<()>
pub async fn inject_response_items( &self, items: Vec<ResponseItem>, ) -> CodexResult<()>
Record raw Responses API items without starting a new turn.
pub fn rollout_path(&self) -> Option<PathBuf>
pub fn session_configured(&self) -> SessionConfiguredEvent
pub async fn guardian_trunk_rollout_path(&self) -> Option<PathBuf>
pub async fn load_history( &self, include_archived: bool, ) -> ThreadStoreResult<StoredThreadHistory>
pub async fn read_thread( &self, include_archived: bool, include_history: bool, ) -> ThreadStoreResult<StoredThread>
pub async fn update_thread_metadata( &self, patch: ThreadMetadataPatch, include_archived: bool, ) -> ThreadStoreResult<StoredThread>
Sourcepub async fn append_rollout_items(
&self,
items: &[RolloutItem],
) -> ThreadStoreResult<()>
pub async fn append_rollout_items( &self, items: &[RolloutItem], ) -> ThreadStoreResult<()>
Appends rollout items through the live thread so derived metadata stays in sync.
pub fn state_db(&self) -> Option<StateDbHandle>
pub async fn config_snapshot(&self) -> ThreadConfigSnapshot
Sourcepub async fn instruction_sources(&self) -> Vec<PathUri>
pub async fn instruction_sources(&self) -> Vec<PathUri>
Returns the files that supplied the thread’s loaded model instructions.
Sourcepub async fn legacy_instruction_sources(&self) -> Vec<LegacyAppPathString>
pub async fn legacy_instruction_sources(&self) -> Vec<LegacyAppPathString>
Returns loaded instruction sources rendered as legacy app-server path strings.
pub async fn config(&self) -> Arc<Config> ⓘ
Sourcepub async fn runtime_mcp_config(&self, config: &Config) -> McpConfig
pub async fn runtime_mcp_config(&self, config: &Config) -> McpConfig
Resolves the MCP runtime configuration using this thread’s extension data.
Sourcepub async fn current_mcp_runtime(&self) -> Arc<McpRuntimeSnapshot> ⓘ
pub async fn current_mcp_runtime(&self) -> Arc<McpRuntimeSnapshot> ⓘ
Returns the exact MCP config, environment bindings, and manager most recently published.
pub fn multi_agent_version(&self) -> Option<MultiAgentVersion>
Sourcepub async fn refresh_runtime_config(&self, next_config: Config)
pub async fn refresh_runtime_config(&self, next_config: Config)
Refresh the thread’s layer-backed user config state from a caller-supplied config snapshot. Thread-scoped layers and session-static settings remain unchanged.
pub async fn environment_selections(&self) -> Vec<TurnEnvironmentSelection>
Sourcepub fn inspect_selected_capability_roots(&self) -> SelectedCapabilityRootsStatus
pub fn inspect_selected_capability_roots(&self) -> SelectedCapabilityRootsStatus
Passively inspects the selected capability roots whose environments are ready now.
pub async fn read_mcp_resource(&self, server: &str, uri: &str) -> Result<Value>
pub async fn call_mcp_tool( &self, server: &str, tool: &str, arguments: Option<Value>, meta: Option<Value>, ) -> Result<CallToolResult>
pub fn enabled(&self, feature: Feature) -> bool
pub async fn increment_out_of_band_elicitation_count(&self) -> CodexResult<i64>
pub async fn decrement_out_of_band_elicitation_count(&self) -> CodexResult<i64>
Auto Trait Implementations§
impl !Freeze for CodexThread
impl !RefUnwindSafe for CodexThread
impl !Unpin for CodexThread
impl !UnsafeUnpin for CodexThread
impl !UnwindSafe for CodexThread
impl Send for CodexThread
impl Sync for CodexThread
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