Represents a Codex conversation thread and exposes turn execution APIs.
Summary
Functions
Returns the most recent account rate limit snapshot for this thread, if any.
Executes a blocking multi-turn run using the agent runner.
Executes an auto-run loop, retrying while a continuation token is present.
Executes a run and returns a stream of events for progressive consumption.
Types
@type t() :: %Codex.Thread{ codex_opts: Codex.Options.t(), continuation_token: String.t() | nil, labels: map(), metadata: map(), pending_tool_failures: [map()], pending_tool_outputs: [map()], rate_limits: Codex.Protocol.RateLimit.Snapshot.t() | map() | nil, resume: :last | nil, thread_id: String.t() | nil, thread_opts: Codex.Thread.Options.t(), transport: :exec | {:app_server, pid()}, transport_ref: reference() | nil, usage: map() }
@type user_input() :: String.t() | [user_input_block()]
@type user_input_block() :: map()
Functions
@spec rate_limits(t()) :: Codex.Protocol.RateLimit.Snapshot.t() | map() | nil
Returns the most recent account rate limit snapshot for this thread, if any.
@spec run(t(), user_input(), map() | keyword()) :: {:ok, Codex.Turn.Result.t()} | {:error, term()}
Executes a blocking multi-turn run using the agent runner.
@spec run_auto(t(), String.t(), keyword()) :: {:ok, Codex.Turn.Result.t()} | {:error, term()}
Executes an auto-run loop, retrying while a continuation token is present.
Options:
:max_attempts– maximum number of attempts (default: 3):backoff– unary function invoked with current attempt (default: exponential sleep):turn_opts– per-turn options forwarded to each attempt
@spec run_streamed(t(), user_input(), map() | keyword()) :: {:ok, Codex.RunResultStreaming.t()} | {:error, term()}
Executes a run and returns a stream of events for progressive consumption.
The stream is lazy; events will not be produced until enumerated.