Curated summary
Speeding up agentic workflows with WebSockets in the Responses API
Codex agent loops spend much of their time on Responses API overhead, not just model inference. As inference sped up, this overhead became the bottleneck. OpenAI cut end-to-end agent loop time by about 40% by caching reusable state and adding WebSocket mode, which keeps a persistent connection open instead of making a series of separate HTTP requests. This let GPT-5.3-Codex-Spark deliver speeds near 1,000 tokens per second, up from roughly 65 on previous flagship models.
Why the API Became the Bottleneck
- A single Codex task, such as fixing a bug, involves dozens of back-and-forth Responses API requests: the model picks an action, a tool runs locally, and the output goes back to the API.
- Inference on GPUs used to dominate latency, so API service overhead was easy to hide. Once inference got faster, the cumulative API overhead became the main cost.
- Early optimizations from a performance sprint around November 2025 included:
- Caching rendered tokens and model configuration in memory to skip tokenization and network calls for multi-turn requests.
- Removing hops to intermediate services, such as image processing, and calling the inference service directly.
- Speeding up the safety stack so certain classifiers could flag conversations faster.
- These changes improved time to first token by about 45%, but they weren't enough for the new model.
- The core problem was structural. Each request was treated as independent, so the full conversation history was reprocessed on every follow-up, making long conversations increasingly expensive.
Designing a Persistent Connection
- The team considered WebSockets and gRPC bidirectional streaming and chose WebSockets. As a simple message transport, it didn't require developers to change their input and output formats.
- The first prototype modeled an entire agentic rollout as one long-running response. When the model made a tool call, the server blocked using asyncio and sent a
response.doneevent to the client. The client ran the tool and returned the result with aresponse.appendevent, and sampling resumed. - This approach treated local tool calls like hosted tool calls. It was very efficient because preinference work ran once, and postinference work ran once at the end. However, its API shape was unfamiliar and complex, so developers would have had to rewrite their integrations.
Keeping the API Familiar
- The launched version kept the standard
response.createrequest body and usedprevious_response_idto continue a conversation. - On each WebSocket connection, the server keeps an in-memory cache scoped to that connection. The cache holds the previous response object, prior input and output items, tool definitions and namespaces, and reusable sampling artifacts such as rendered tokens.
- Reusing this cached state enabled several optimizations:
- Safety classifiers and request validators process only new input instead of the full history.
- Rendered tokens are appended to a cache, avoiding repeated tokenization.
- Model resolution and routing decisions are reused across requests.
- Non-blocking postinference work, such as billing, overlaps with subsequent requests.
Results
- After a two-month build, an alpha with major coding agent startups reported up to 40% faster agentic workflows.
- At launch, Codex moved most of its Responses API traffic to WebSocket mode. GPT-5.3-Codex-Spark reached its 1,000 tokens-per-second target and hit bursts of up to 4,000.
- Partner results included:
- Vercel's AI SDK: latency reduced by up to 40%.
- Cline: multi-file workflows 39% faster.
- Cursor: OpenAI models up to 30% faster.
WebSocket mode is one of the most significant additions to the Responses API since its March 2025 launch. As model inference speeds up, the surrounding infrastructure must speed up too, or users won't see the gains.
Related reading
Continue with another curated summary.