Codex 0.168 shipped two transport changes merged hours apart: background recovery to WebSocket, then sticky HTTP for the session. Three fallback policies modelled and compared.
Two transports for one conversation
Agent clients can talk to model APIs over a long-lived WebSocket rather than a separate HTTP request per turn. A persistent connection can avoid repeated setup, although HTTP clients can also reuse pooled connections. An API that supports incremental input can reduce repeated context transfer; that capability comes from the API contract, not WebSocket alone. But WebSockets can encounter upgrade restrictions, idle timeouts and dropped long-lived connections. So a client that prefers WebSocket needs a fallback to HTTP, and a policy for what happens after it falls back.
Codex CLI rust-v0.168.0, released on 13 November 2026, contains two pull requests on exactly this question, merged a few hours apart on 2 November, that point in opposite directions. Reading them together is a compact lesson in transport policy.
Pull request 58950, "Recover WebSocket transport after transient HTTP fallback", says that a transient WebSocket failure previously kept the session on HTTP for its remaining lifetime even if WebSocket connectivity recovered. It added background probes of WebSocket connectivity during HTTP fallback, verification of recovery with a real request whose first-response wait is bounded to five seconds, HTTP 426 responses and recovery timeouts keeping the session on HTTP, retries of an HTTP request staying on HTTP, a rule that a recovered connection failing before output replays the request over HTTP without consuming its ordinary retry budget while failures after output use normal retry accounting, and rate-limited probes honouring Retry-After.
Pull request 58989, "Keep HTTP fallback active for the rest of the session", merged later the same day, says that once requests fall back to HTTP after exhausting WebSocket retries or receiving HTTP 426, subsequent requests and turns stay on HTTP for the remainder of the session, and that it clears cached WebSocket state and removes the background recovery probes, recovery trials and their acknowledgement timeout.
Both are listed in the 0.168.0 changelog. The net behaviour of the release, as far as those descriptions go, is sticky fallback: after WebSocket gives up, the session uses HTTP until it ends. This guide does not describe Codex code beyond the two descriptions; it models the three policies they span.
Three policies
Per-request fallback tries WebSocket for every request and falls back to HTTP only for the request that failed. It recovers instantly when the network does, and pays the full WebSocket retry cost on every request while the network is bad.
Sticky fallback, the 0.168.0 behaviour, falls back once and stays. It pays the retry cost once per session and never again, and it never recovers within the session.
Probe and recover, the behaviour 58950 added and 58989 removed, falls back, keeps probing WebSocket in the background, and switches back after a probe succeeds. It recovers within a session at the cost of probes, a recovery handshake, and much more state: probe scheduling, a verification request, and the accounting rules for a recovered connection that fails again.
A scripted comparison
The companion model runs each policy over three synthetic eight-request sessions, two WebSocket retries per request, for the fictional Belgavi's Book Store support agent. W means a request went over WebSocket, H over HTTP.
network policy transports ws attempts probes ws retries
transient outage per-request WWHHWWWW 12 0 6
(reqs 3-4 fail) sticky WWHHHHHH 5 0 3
probe/recover WWHHWWWW 9 2 3
proxy answers 426 any policy HHHHHHHH 1 0 0
flapping link per-request WHWHWHWH 16 0 12
(every other fails) sticky WHHHHHHH 4 0 3
probe/recover WHWHWHWH 16 3 12The model is simple, and its network does not change within a request, but it shows the trade-off clearly. Probing wins a transient outage in a long session. On a flapping link, probing recovers into the same failure over and over, and does no better than per-request fallback while adding probe traffic. Sticky fallback is the most predictable: one bad stretch costs one round of retries, and the rest of the session is plain HTTP.
Why sticky is a reasonable default
Several properties of agent sessions favour sticky fallback.
Failures cluster. A network that dropped one WebSocket is likely to drop the next: the same proxy, the same idle timeout, the same flaky Wi-Fi. A policy that keeps re-trying the failing transport turns one diagnosis into many.
Recovery is not free to get right. The 58950 description lists the rules a recovering client needs: verify with a real request, bound the wait, keep 426 sticky, keep retries of an HTTP request on HTTP, replay a request that failed before output without charging its retry budget, charge failures after output normally, rate-limit probes and honour Retry-After. Each rule is reasonable. Together they are a state machine that runs only when the network is already misbehaving, which is the hardest time to debug it.
Mid-stream failures are expensive. A failure after the model has started producing output means some output was shown and some tokens were paid for. Replaying it can repeat output. A transport policy that causes more mid-stream failures, by switching back to a transport that then fails again, costs more than its latency savings.
Sessions end. A coding or support session is minutes to hours. Starting the next session on WebSocket is a natural, cheap recovery point, and it needs no extra code: the new session simply begins with the preferred transport, and the old one's history of failures does not follow it.
A 426 response needs a protocol-specific policy
HTTP 426 Upgrade Required means the server refuses the current protocol but may accept a different one, which it must identify in an Upgrade header (RFC 9110, section 15.5.22). The status alone does not establish that a proxy blocked WebSocket or that WebSocket can never work. The cited Codex changes give this response a specific meaning in their model-request transport policy: keep HTTP fallback active for that session. The synthetic model adopts that policy, so its 426 fixture makes one WebSocket attempt followed by eight HTTP requests. Other clients should inspect the response and their endpoint contract before adopting the same rule.
Accounting that matters regardless of policy
Separate failures before output from failures after output. Before output, no result has reached the user, but the server may already have accepted or executed the request. Replay safety depends on the operation and the endpoint's deduplication or idempotency guarantees; silence alone proves neither. Use a stable request identity where supported, and reconcile an uncertain outcome before repeating side effects. Whether a permitted replay consumes the ordinary retry budget is a separate policy choice: 58950 exempted its described recovery replay. After output, also discard or reconcile the partial response before any replay and account for the extra attempt.
Keep retries of a request on the transport that is serving it. Switching transports in the middle of one request's retry loop makes the retry count meaningless and the logs hard to read.
Record the transport on every request in your telemetry. Without it, a latency regression caused by a silent fallback to HTTP looks like a slow model.
What stays deterministic
Transport choice is client policy. The model and the agent's planning never see it. Make it explicit configuration with a logged reason for each switch, so a support engineer can see "fell back to HTTP after 3 WebSocket attempts at 10:42, stayed for the session".
When to choose differently
Probe-and-recover earns its complexity for very long sessions on networks where outages are known to be transient, such as an always-on service rather than an interactive client. Per-request fallback suits a client whose requests are independent and short, where there is no session to be sticky to. For most interactive agent clients, sticky-per-session is the one with the fewest surprises, and it is what Codex 0.168.0 ships.
Verify it
Run the companion model and change its scripts. In your own client, return a controlled 426 fixture and assert the configured session policy; test repeated upgrade failures separately from that response. Drop the socket before the first output and after partial output. Check request identity, whether the server accepted the operation, replay eligibility and partial-result handling in each case. Assert the transport and retry count for every request, including an ambiguous failure that must remain pending rather than being replayed blindly.
Run the example yourself
The per-request, sticky and probing fallback policies run over three network scripts, with six tests. It does not reproduce Codex internals. Companion code on GitHub; its README lists the prerequisites, exact commands, expected output and limits.