GPT WORLD / INDEPENDENT CODEX FIELD MANUAL Source review · 2026-07-31

Retrospective edition / UX

Design streaming as a state machine

A useful stream distinguishes start, typed deltas, tool activity, completion, cancellation, and failure rather than appending arbitrary text.

01 / DECIDE

Architecture decision

Use it when perceived latency and progressive feedback matter more than receiving one final payload.

A useful stream distinguishes start, typed deltas, tool activity, completion, cancellation, and failure rather than appending arbitrary text. Map input, output, state, and side effects as one observable path before deciding which layer owns design streaming as a state machine.

02 / BUILD

Three-step implementation

  1. 01

    Frame the contract

    Write down the caller, data classification, success condition, timeout, cancellation, and ownership. Use it when perceived latency and progressive feedback matter more than receiving one final payload.

  2. 02

    Build one narrow path

    Implement one end-to-end path with request correlation, typed state, and reversible failure handling. A useful stream distinguishes start, typed deltas, tool activity, completion, cancellation, and failure rather than appending arbitrary text.

  3. 03

    Prove the outcome

    Turn acceptance into a repeatable fixture, contract test, or browser test. Browser tests exercise abort, reconnect, slow consumer, malformed event, and a tool call interleaved with text.

03 / BOUND

Production boundary

Partial text is untrusted and may be revised; do not trigger side effects or persist a final record until terminal events pass validation.

04 / PROVE

Acceptance evidence

Browser tests exercise abort, reconnect, slow consumer, malformed event, and a tool call interleaved with text.

SOURCE / HTTP

Reproducible source probe

curl -fsSI 'https://developers.openai.com/api/docs/guides/streaming-responses' | sed -n '1,5p'