Files
codex/codex-rs/codex-api
Charlie Marsh 9f2b87495b Recover server replies after Responses WebSocket write failures (#62749)
## Why

A server can reject an oversized request after reading just the first
frame header. If the upload then fails with a broken pipe, the write
error can hide the server's message-too-large close.

## What changed

After a write fails partway through an upload, drain immediately
readable replies within the send deadline and a bounded read budget.
Use those replies to surface server errors, including
`WebsocketMessageTooLarge`. Treat a close seen before the first frame
as belonging to the idle connection, and retire the socket after a
failed send.

## Testing

Add regression tests for size-limit closes on an idle socket, just
before the first frame, and after a partial first-frame write fails
with pings and pongs ahead of the close.

GitOrigin-RevId: 2feeb1961992b425dbec06129015dbe4c44ff3f2
2026-11-20 12:22:56 +00:00
..

codex-api

Typed clients for Codex/OpenAI APIs built on top of the generic transport in codex-client.

  • Hosts the request/response models and request builders for Responses and related Codex APIs.
  • Owns provider configuration (base URLs, headers, query params), auth header injection, retry tuning, and stream idle settings.
  • Parses SSE streams into ResponseEvent/ResponseStream, including rate-limit snapshots and API-specific error mapping.
  • Serves as the wire-level layer consumed by codex-core; higher layers handle auth refresh and business logic.

Core interface

The public interface of this crate is intentionally small and uniform:

  • Responses endpoint

    • Input:
      • ResponsesApiRequest for the request body (model, input, tools, parallel_tool_calls, reasoning/text controls).
      • ResponsesOptions for transport/header concerns (conversation_id, session_source, extra_headers, compression, turn_state).
    • Output: a ResponseStream of ResponseEvent (both re-exported from common).
  • Memory summarize endpoint

    • Input: MemorySummarizeInput (re-exported as codex_api::MemorySummarizeInput):
      • model: String.
      • raw_memories: Vec<RawMemory> (serialized as traces for wire compatibility).
        • RawMemory includes id, metadata.source_path, and normalized items.
      • reasoning: Option<Reasoning>.
    • Output: Vec<MemorySummarizeOutput>.
    • MemoriesClient::summarize_input(&MemorySummarizeInput, extra_headers) wraps JSON encoding and retry/telemetry wiring.

All HTTP details (URLs, headers, retry/backoff policies, SSE framing) are encapsulated in codex-api and codex-client. Callers construct prompts/inputs using protocol types and work with typed streams of ResponseEvent or other endpoint-specific response values.