Speeding up agentic workflows with WebSockets in the Responses API
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.
Related posts
- From model to agent: Equipping the Responses API with a computer environment
OpenAI mediumAdept
OpenAI's Responses API now pairs with a shell tool and hosted container workspace so models can run multi-step agent workflows. The API orchestrates the loop itself: it streams command output back to the model, runs multiple commands concurrently in separate sessions, and truncates large outputs while keeping their beginning and end. Native compaction carries long-running sessions across context-window limits. The containers stage files and SQLite databases instead of stuffing prompts, route network egress through a sidecar proxy with allowlists and domain-scoped secret injection, and load versioned 'skills' bundles (SKILL.md plus resources) that the model explores via shell commands.
- Break chatbot speed limits with speculative tool calls
incident.io mediumAdeptincident.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. Tools are started in parallel with the main chat prompt when simple keyword matching suggests they will be needed, and the follow-up chat prompt is run optimistically by assuming the tool succeeded, then re-run on error. Side effects are prevented with a Go write barrier: speculative tools do all their LLM 'thinking' but block before writing until the main prompt confirms the call, otherwise the context is cancelled. The tradeoff is occasional wasted LLM spend, which effectively lets the team buy speed with money.
- Unrolling the Codex agent loop
OpenAI mediumAdept
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. The initial prompt is assembled from three parts: instructions from config or bundled model files, a tools list (shell, update_plan, web_search, MCP tools), and ordered input items. Those input items cover sandbox permissions, developer instructions, aggregated AGENTS.md user instructions (32 KiB limit), skills and environment context. Responses stream back as SSE events, and reasoning and function-call items are fed back into later requests, so prompt length grows and context-window management becomes a core harness responsibility.
- AI Agent Latency 101: How do I speed up my AI agent?
LangChain easyNoviceAI 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. Streaming intermediate steps such as plans, retrieval results or thinking tokens can raise user satisfaction without changing total time, and event-triggered background agents hide latency entirely. General-purpose multi-agent supervisor or swarm setups make many LLM calls, so mixing code with explicitly routed calls reduces them. Smaller models and shorter context speed up individual calls at some cost to accuracy, and guardrail checks, multi-document extraction or multi-model calls can run concurrently.
- Optimizing LLM prompts for low latency
incident.io mediumAdeptincident.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. Dropping JSON reasoning fields halved output tokens (315 to 170) and saved about 40% latency. Replacing JSON dashboard definitions with a compact custom format cut input from 15k to 2k tokens but saved only about 20%. A terse non-JSON output format cut output tokens by a further 70% and latency by 60%, though the team held back from shipping it because models are more familiar with JSON and quality could suffer in subtle ways.