Skip to main content

CodexThread

Struct CodexThread 

Source
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.

Source

pub async fn submit(&self, op: Op) -> CodexResult<String>

Source

pub fn session_telemetry(&self) -> SessionTelemetry

Returns the session telemetry handle for thread-scoped production instrumentation.

Source

pub async fn shutdown_and_wait(&self) -> CodexResult<()>

Source

pub async fn wait_until_terminated(&self)

Wait until the underlying session loop has terminated.

Source

pub async fn emit_thread_idle_lifecycle_if_idle(&self)

Source

pub async fn submit_with_trace( &self, op: Op, trace: Option<W3cTraceContext>, ) -> CodexResult<String>

Source

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>

Source

pub async fn set_thread_memory_mode(&self, mode: ThreadMemoryMode) -> Result<()>

Persist whether this thread is eligible for future memory generation.

Source

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>

Source

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.

Source

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.

Source

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<()>

Source

pub async fn set_openai_form_elicitation_support( &self, supported: bool, ) -> Result<()>

Source

pub async fn preview_thread_settings_overrides( &self, overrides: CodexThreadSettingsOverrides, ) -> ConstraintResult<ThreadConfigSnapshot>

Preview persistent thread settings overrides without committing them.

Source

pub async fn submit_with_id(&self, sub: Submission) -> CodexResult<()>

Use sparingly: this is intended to be removed soon.

Source

pub async fn next_event(&self) -> CodexResult<Event>

Source

pub async fn agent_status(&self) -> AgentStatus

Source

pub async fn list_background_terminals(&self) -> Vec<BackgroundTerminalInfo>

Source

pub async fn terminate_background_terminal(&self, process_id: i32) -> bool

Source

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.

Source

pub async fn inject_response_items( &self, items: Vec<ResponseItem>, ) -> CodexResult<()>

Record raw Responses API items without starting a new turn.

Source

pub fn rollout_path(&self) -> Option<PathBuf>

Source

pub fn session_configured(&self) -> SessionConfiguredEvent

Source

pub async fn guardian_trunk_rollout_path(&self) -> Option<PathBuf>

Source

pub async fn load_history( &self, include_archived: bool, ) -> ThreadStoreResult<StoredThreadHistory>

Source

pub async fn read_thread( &self, include_archived: bool, include_history: bool, ) -> ThreadStoreResult<StoredThread>

Source

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

Source

pub async fn append_rollout_items( &self, items: &[RolloutItem], ) -> ThreadStoreResult<()>

Appends rollout items through the live thread so derived metadata stays in sync.

Source

pub fn state_db(&self) -> Option<StateDbHandle>

Source

pub async fn config_snapshot(&self) -> ThreadConfigSnapshot

Source

pub async fn instruction_sources(&self) -> Vec<PathUri>

Returns the files that supplied the thread’s loaded model instructions.

Source

pub async fn legacy_instruction_sources(&self) -> Vec<LegacyAppPathString>

Returns loaded instruction sources rendered as legacy app-server path strings.

Source

pub async fn config(&self) -> Arc<Config>

Source

pub async fn runtime_mcp_config(&self, config: &Config) -> McpConfig

Resolves the MCP runtime configuration using this thread’s extension data.

Source

pub async fn current_mcp_runtime(&self) -> Arc<McpRuntimeSnapshot>

Returns the exact MCP config, environment bindings, and manager most recently published.

Source

pub fn multi_agent_version(&self) -> Option<MultiAgentVersion>

Source

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.

Source

pub async fn environment_selections(&self) -> Vec<TurnEnvironmentSelection>

Source

pub fn inspect_selected_capability_roots(&self) -> SelectedCapabilityRootsStatus

Passively inspects the selected capability roots whose environments are ready now.

Source

pub async fn read_mcp_resource(&self, server: &str, uri: &str) -> Result<Value>

Source

pub async fn call_mcp_tool( &self, server: &str, tool: &str, arguments: Option<Value>, meta: Option<Value>, ) -> Result<CallToolResult>

Source

pub fn enabled(&self, feature: Feature) -> bool

Source

pub async fn increment_out_of_band_elicitation_count(&self) -> CodexResult<i64>

Source

pub async fn decrement_out_of_band_elicitation_count(&self) -> CodexResult<i64>

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