Speeding up agentic workflows with WebSockets in the Responses API
OpenAI
OpenAI swapped how Codex talks to its API, moving from repeated HTTP calls to a persistent WebSocket connection. Less overhead per turn means faster replies in agent loops that fire off tons of small requests.
Based on reporting by OpenAI — read the original for the full story.
Summary, retelling and take written by AI under human oversight; images are AI-generated illustrations. How we work · Report an error
Agent loops are chatty. Every time Codex takes a step, plans a move, or checks a tool result, it's firing another request at the model. Do that over standard HTTP and you're paying a tax on every single call: new connection setup, repeated headers, redundant context getting re-sent again and again. OpenAI's engineers looked at that tax bill for the Responses API and decided it was too high.
Their fix was to open a WebSocket once per session and keep it alive for the life of the agent loop, rather than tearing down and rebuilding a connection for every turn. On top of that, they added connection-scoped caching, so information tied to that specific session sticks around locally instead of getting shipped back and forth with each request. The combination cuts out a meaningful chunk of the round-trip overhead that piles up when an agent is taking dozens or hundreds of steps to finish a task.
The numbers matter here because Codex isn't a chatbot answering one question. It's closer to a loop that reasons, calls tools, reads output, and reasons again, sometimes for minutes at a stretch. Shaving latency off each of those steps compounds fast. A few hundred milliseconds saved per turn turns into real, noticeable speedups once you're running an agent through fifty or a hundred iterations on a coding task.
This is also a quiet admission that the request-response model, the thing the web has run on for three decades, isn't a great fit for how agentic systems actually behave. Agents don't ask one question and walk away. They loop, they backtrack, they hold state. Building infrastructure that assumes a single stateless exchange per interaction was always going to strain under that pattern, and OpenAI's move toward persistent connections is a tacit acknowledgment of that mismatch.
My take — AI-written commentary, not fact-checked reporting
This is the kind of unglamorous plumbing work that actually matters more than another benchmark chart, because agent products live or die on latency, not just raw model quality. I'd bet every other lab building agentic tooling quietly ships the same WebSocket fix within the year, they just won't blog about it.
Read more about this at: OpenAI