Codex.RunResultStreaming (Codex SDK v0.6.0)

Copy Markdown View Source

Streaming result wrapper exposing semantic and raw event streams plus cancellation controls.

Summary

Functions

Returns a stream of semantic events. Automatically starts the underlying streaming process on first invocation.

Pops the next semantic event from the queue, blocking up to timeout.

Returns a stream of the raw Codex events.

Returns the aggregated usage captured so far.

Types

t()

@type t() :: %Codex.RunResultStreaming{
  control: pid(),
  queue: pid(),
  start_fun: (-> any())
}

Functions

cancel(run_result_streaming, mode \\ :immediate)

@spec cancel(t(), :immediate | :after_turn) :: :ok

Cancels the streaming run.

Modes:

  • :immediate - stop immediately
  • :after_turn - finish the current turn then halt

events(result)

@spec events(t()) :: Enumerable.t()

Returns a stream of semantic events. Automatically starts the underlying streaming process on first invocation.

pop(result, timeout \\ 5000)

@spec pop(t(), timeout()) :: {:ok, term()} | {:error, term()} | :done

Pops the next semantic event from the queue, blocking up to timeout.

Returns {:error, reason} if the stream terminates with an error.

raw_events(result)

@spec raw_events(t()) :: Enumerable.t()

Returns a stream of the raw Codex events.

usage(run_result_streaming)

@spec usage(t()) :: map()

Returns the aggregated usage captured so far.