openai/codex · error · CodexErr

shared rollout token budget exhausted

Error message

shared rollout token budget exhausted

What it means

Semantic category signaling that a shared rollout (a session resumed/compacted across multiple threads) hit its hard token budget for the whole rollout. It fires when cumulative token usage across the shared rollout exceeds the configured cap, refusing further turns on that rollout.

Solutions

  1. Start a fresh thread/rollout instead of continuing the exhausted one
  2. Clear or compact earlier history to reduce rollout size before retrying
  3. Review the token budget configuration if the cap seems too low for the workload
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at codex-rs/protocol/src/error.rs:85 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/d315784a4c376909. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/protocol/src/error.rs:85

    LandlockRestrict,
}

pub struct CodexErr {
    details: CodexErrorDetails,
    retry_delay: Option<Duration>,
}

/// The semantic category and diagnostic payload for a [`CodexErr`].
#[derive(Error, Debug, EnumDiscriminants)]
#[strum_discriminants(name(CodexErrKind))]
#[strum_discriminants(derive(serde::Serialize))]
#[strum_discriminants(serde(rename_all = "snake_case"))]
#[strum_discriminants(doc = "The payload-free semantic category used for analytics.")]
pub enum CodexErrorDetails {
    #[error("turn aborted. Something went wrong? Hit `/feedback` to report the issue.")]
    TurnAborted,

    #[error("shared rollout token budget exhausted")]
    SessionBudgetExceeded,

    /// Returned by ResponsesClient when the SSE stream disconnects or errors out **after** the HTTP
    /// handshake has succeeded but **before** it finished emitting `response.completed`.
    ///
    /// The Session loop treats this as a transient error and will automatically retry the turn.
    #[error("stream disconnected before completion: {0}")]
    Stream(String),
    #[error(
        "Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying."
    )]
    ContextWindowExceeded,
    #[error("no thread with id: {0}")]
    ThreadNotFound(ThreadId),
    #[error("agent thread limit reached")]
    AgentLimitReached { max_threads: usize },
    #[error("session configured event was not the first event in the stream")]
    SessionConfiguredNotFirstEvent,

View on GitHub (pinned to 339751715c)