Skip to content

Surface non-content stream status in the turn status UI #28445

Open

Description

@softkleenex

Summary

I ran into a case where a streaming Responses-compatible provider needs to send a non-content status update while a turn is still in progress. The specific use case is an account-capacity wait: the stream is still alive, but no model content is available yet, so the CLI should surface a transient status instead of adding anything to the transcript.

I prepared a small branch that adds a generic ResponseEvent::StreamStatus path and forwards it through the existing turn status surface. The parser currently maps codex.keepalive events with status: "waiting_for_account_capacity" into that generic status event.

Compare branch:
https://github.com/openai/codex/compare/main...softkleenex:dex/stream-status-events?expand=1

I tried opening this as a PR, but the repository currently limits PR creation to collaborators, so I'm sharing the branch here instead.

Why

This lets a stream report transient backend/provider state without injecting assistant text or user-visible transcript content. It reuses the existing StreamError/retry status UI path, so the turn can still complete normally after the status update.

Test plan run locally

  • just test -p codex-api
  • just test -p codex-core keepalive_stream_status_emits_stream_error_status
  • just test -p codex-otel
  • git diff --check origin/main...HEAD

Activity

  1. added
    enhancement
    CLI
    TUI
    on Jun 16, 2026
  2. MakenRosa commented on Jun 17, 2026

    @MakenRosa

    I reviewed the linked branch/diff against current main. The approach is technically small and targets the right layer, but I would separate "stream status" semantics from "stream error" before merging.

    What the branch currently does:

    • Adds ResponseEvent::StreamStatus { message, details } in codex-api.
    • Parses codex.keepalive with status = "waiting_for_account_capacity" in codex-rs/codex-api/src/sse/responses.rs.
    • Formats details from retry_after_seconds, waited_seconds, and reason.
    • Maps that new response event to EventMsg::StreamError(StreamErrorEvent { ... }) in codex-rs/core/src/session/turn.rs.
    • Excludes StreamStatus from TTFT in codex-rs/core/src/turn_timing.rs.
    • Adds tests for SSE parsing and the core event path.

    That is a good proof of concept. The main concern is the protocol/UI boundary: waiting_for_account_capacity is a transient non-content status while the stream is still alive, not an error. Reusing StreamError may work with existing TUI surfaces, but it risks error-colored UI, error telemetry semantics, and future confusion for clients that interpret StreamError as a degraded/failed stream.

    A cleaner shape would be:

    • Keep ResponseEvent::StreamStatus in codex-api.
    • Add a distinct protocol event, e.g. EventMsg::StreamStatus(StreamStatusEvent { message, details }) or a more generic TurnStatusUpdate.
    • Let TUI render it as a transient status while the turn remains in progress.
    • Keep StreamError for actual stream failures/retry-exhaustion.

    The branch is also SSE-only. If websocket streaming can receive the same codex.keepalive / capacity status, the websocket event mapping should get parity or the UX will differ by transport.

    Test gap I would add: a TUI/client-level assertion that receiving the status event during an active turn does not add a permanent error history cell and does not mark the turn failed. Current TUI tests already assert replayed StreamError does not add a history cell, but that is still relying on an error-shaped event for a non-error state.

    Overall: this is worth doing, and the branch identifies the right event source. I would just avoid encoding a live wait/status as StreamError in the public protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLITUIenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions