---
title: "Speeding up agentic workflows with WebSockets in the Responses API"
description: "OpenAI cut end-to-end latency of agentic loops on the Responses API by about 40% by adding a WebSocket mode that keeps a persistent connection with a connection-scoped in-memory cache of prior response state."
url: "https://swe.quest/articles/speeding-up-agentic-workflows-with-websockets-in-the-responses-api-7a1ff127c7fc35a3"
canonical: "https://openai.com/index/speeding-up-agentic-workflows-with-websockets"
source: "OpenAI"
published: "2026-04-22"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["ai-agents","api-design","performance","inference","realtime"]
---

# Speeding up agentic workflows with WebSockets in the Responses API

A post on [OpenAI](https://swe.quest/sources/openai.md), published 2026-04-22, 6 min read, Case study. Original: [https://openai.com/index/speeding-up-agentic-workflows-with-websockets](https://openai.com/index/speeding-up-agentic-workflows-with-websockets)

## Summary

OpenAI cut end-to-end latency of agentic loops on the Responses API by about 40% by adding a WebSocket mode that keeps a persistent connection with a connection-scoped in-memory cache of prior response state. Follow-up \`response.create\` calls with \`previous\_response\_id\` reuse cached rendered tokens, tool definitions and routing, so safety classifiers and validators process only new input, and postinference work like billing overlaps with later requests. An earlier prototype that modeled the whole rollout as one long-running response blocked on client tool calls was faster still, but it was dropped in favor of keeping the familiar API shape. Earlier sprint work (token and config caching, fewer network hops, faster safety checks) improved TTFT by about 45%, and the WebSocket mode let GPT-5.3-Codex-Spark reach 1,000+ TPS, with partners such as Cline, Vercel and Cursor reporting 30-40% speedups.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Real-time systems](https://swe.quest/tags/realtime.md) (Backend & APIs)

## Prerequisites

- HTTP request/response APIs ([easy posts on API design](https://swe.quest/tags/api-design.md?difficulty=easy))
- WebSockets ([easy posts on Real-time systems](https://swe.quest/tags/realtime.md?difficulty=easy))
- LLM agent tool-calling loops ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))

## Keywords

Responses API, WebSockets, Codex, GPT-5.3-Codex-Spark, Cerebras, previous\_response\_id

## Related posts

- [From model to agent: Equipping the Responses API with a computer environment](https://swe.quest/articles/from-model-to-agent-equipping-the-responses-api-with-a-computer-environment-102e043c05e5f9e2.md): OpenAI · 2026-03-11 · Medium · 10 min read · AI agents, LLMs, Sandboxing & isolation, System design
  OpenAI's Responses API now pairs with a shell tool and hosted container workspace so models can run multi-step agent workflows.
- [Break chatbot speed limits with speculative tool calls](https://swe.quest/articles/break-chatbot-speed-limits-with-speculative-tool-calls-83dbf2c2a180290f.md): incident.io · 2025-03-25 · Medium · 10 min read · AI agents, LLMs, Performance engineering, Go
  incident.io cut its incident chatbot's response latency by about 50% (saving 2-3s per interaction) by speculatively executing LLM tool calls in both directions.
- [Unrolling the Codex agent loop](https://swe.quest/articles/unrolling-the-codex-agent-loop-9f9b82453a544efc.md): OpenAI · 2026-01-23 · Medium · 16 min read · AI agents, AI for coding, LLMs, Developer tools
  Codex CLI's agent loop repeatedly sends a prompt to the Responses API, executes any tool calls the model requests, and appends their outputs until the model returns an assistant message that ends the turn.
- [AI Agent Latency 101: How do I speed up my AI agent?](https://swe.quest/articles/ai-agent-latency-101-how-do-i-speed-up-my-ai-agent-62a7a640683900cd.md): LangChain · 2026-08-26 · Easy · 5 min read · AI agents, Performance engineering, LLMs
  AI agent latency can be cut in five ways: find the bottleneck first (e.g. with per-step tracing and a waterfall view), reduce perceived latency through UX, make fewer LLM calls, make each call faster, and run calls in parallel.
- [Optimizing LLM prompts for low latency](https://swe.quest/articles/optimizing-llm-prompts-for-low-latency-a98e3093827ae50c.md): incident.io · 2025-03-25 · Medium · 9 min read · LLMs, Performance engineering, Inference & serving
  incident.io cut latency of an LLM prompt that plans Grafana dashboards for incident investigations from 11s to under 2.3s without changing its behaviour, mainly by shrinking output tokens.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
