Codex.Thread (Codex SDK v0.3.0)

View Source

Represents a Codex conversation thread and exposes turn execution APIs.

Summary

Functions

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

t()

@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()],
  thread_id: String.t() | nil,
  thread_opts: Codex.Thread.Options.t(),
  transport: :exec | {:app_server, pid()},
  transport_ref: reference() | nil,
  usage: map()
}

Functions

run(thread, input, opts \\ %{})

@spec run(t(), String.t(), map() | keyword()) ::
  {:ok, Codex.Turn.Result.t()} | {:error, term()}

Executes a blocking multi-turn run using the agent runner.

run_auto(thread, input, opts \\ [])

@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

run_streamed(thread, input, opts \\ %{})

@spec run_streamed(t(), String.t(), 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.