Skip to content

Speculative prewarm (generate:false) for the Codex WebSocket transport #47

Description

@amondnet

Summary

Evaluate and (if worthwhile) implement speculative prewarm (generate:false) on the Codex WebSocket transport — opening/priming the socket and server-side context before the first real turn, to shave first-token latency. Currently explicitly out of scope.

Why

Real Codex uses a generate:false prewarm to keep a connection warm and the context primed so the first billable turn starts faster. shunt already pools connections per session, so the remaining latency is the handshake + initial context upload on the first turn of a conversation. Prewarm targets exactly that. This is a pure latency optimization — no correctness impact — so it's lower priority than the correctness/robustness WS items, and should follow the live-probe work (so we trust continuation before adding speculative turns).

See docs/comparison.md §6 item D.

Tasks

  • Confirm the generate:false frame semantics against real Codex WS traffic (what it returns, whether it establishes a reusable previous_response_id).
  • Decide the trigger: on session start? on first /v1/messages for a new session id? (avoid prewarming sessions that never send a turn).
  • Measure first-token latency with vs without prewarm before committing.
  • Gate behind the existing websocket opt-in (and possibly a separate prewarm flag); keep it inert on non-Codex backends.

Evidence

  • docs/m7-codex-websocket.md:53-58 (prewarm listed as out of scope)
  • src/adapters/codex_ws.rs (pooling, response.create framing)

Related

  • Comparison: docs/comparison.md
  • Prerequisite: live-probe the continuation normalization first

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions