fix(proxy): surface codex websocket loop failures in livez#1727
Merged
chopratejas merged 2 commits intoJul 3, 2026
Merged
Conversation
Contributor
PR governanceThis PR follows the template and is marked ready for human review. |
66decaf to
48baf78
Compare
48baf78 to
a884be0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Codex
/v1/responsesWebSocket disconnects can trigger a knownwebsocketscallback failure beforeconnection_made()initializesrecv_messages. When that happens, the proxy process can stay alive while/livezkeeps advertising a clean healthy state. This change contains that known callback failure in the proxy runtime, records loop callback health, and makes/livezreport the degraded state instead of always returning a clean process-alive payload. Closes #1720Type of Change
Changes Made
websocketsconnection_lostClientConnection.recv_messagesAttributeError, records it in bounded runtime health state, and leaves unrelated loop exceptions delegated to the previous or default handler./livezso the route remains cheap and unauthenticated while reflecting recorded event-loop callback health instead of always reporting a clean process-alive payload.Testing
uv run pytest tests/test_proxy_healthchecks.py tests/test_openai_codex_ws_lifecycle.py tests/test_proxy_loop_exception_health.py -q)uv run ruff check headroom/proxy/server.py tests/test_proxy_healthchecks.py tests/test_openai_codex_ws_lifecycle.py tests/test_proxy_loop_exception_health.pyanduv run ruff format --check headroom/proxy/server.py tests/test_proxy_healthchecks.py tests/test_openai_codex_ws_lifecycle.py tests/test_proxy_loop_exception_health.py)uv run mypy headroom)Test Output
Real Behavior Proof
Connection.connection_lostplusAttributeError("'ClientConnection' object has no attribute 'recv_messages'"), then request/livez.websocketscallback failure is recorded without delegating to the noisy default handler,/livezreports degraded loop callback health (HTTP 503,"status": "unhealthy","alive": false), and unrelated callback exceptions still reach the delegated handler.websocketstiming edge against a live network connection; the focused regression pins the callback shape reported in [BUG] Proxy silently wedges (no crash, /livez hangs) after websockets connection_lost AttributeError #1720.Review Readiness
Checklist
Additional Notes
CHANGELOG.mdis release-managed from conventional commits, so this PR does not edit it manually. The scope stays inside the proxy runtime and Codex WebSocket dispatch path; it does not change compression, CCR, provider-neutral pipeline behavior, or generic transform modules.