From 97ea3d13d8f5549bc6c6f693ac3f4bfa92f71e22 Mon Sep 17 00:00:00 2001 From: axelray-dev <110029405+axelray-dev@users.noreply.github.com> Date: Thu, 16 Jul 2026 03:44:54 +0800 Subject: [PATCH] fix(oauth): send Codex client version header on upstream requests Upstream gates newer models on a version header. Attach resolve_codex_version() when non-empty so completions match /models. Fixes #1765 --- plugins/_oauth/helpers/codex.py | 3 +++ tests/test_oauth_codex.py | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/_oauth/helpers/codex.py b/plugins/_oauth/helpers/codex.py index adcfdaec6e..b414592d15 100644 --- a/plugins/_oauth/helpers/codex.py +++ b/plugins/_oauth/helpers/codex.py @@ -599,6 +599,9 @@ def request_codex( "thread-id": metadata["thread_id"], } ) + client_version = resolve_codex_version() + if client_version: + request_headers["version"] = client_version return requests.request( method, diff --git a/tests/test_oauth_codex.py b/tests/test_oauth_codex.py index fc4a3159fb..58d8e6b989 100644 --- a/tests/test_oauth_codex.py +++ b/tests/test_oauth_codex.py @@ -223,7 +223,10 @@ def test_prepare_responses_body_sends_empty_continuation_input_as_list(monkeypat assert body["previous_response_id"] == "resp_1" -def test_request_codex_sends_current_codex_headers_from_body(monkeypatch): +@pytest.mark.parametrize("client_version", ["0.142.5", ""]) +def test_request_codex_sends_current_codex_headers_from_body( + monkeypatch, client_version +): calls = [] body = json.dumps( { @@ -255,6 +258,7 @@ class FakeResponse: account_id="account-1", ), ) + monkeypatch.setattr(codex, "resolve_codex_version", lambda: client_version) def fake_request(method, target, headers, data, params, timeout, stream): calls.append( @@ -291,6 +295,10 @@ def fake_request(method, target, headers, data, params, timeout, stream): assert call["headers"]["session-id"] == "session-1" assert call["headers"]["thread-id"] == "thread-1" assert call["headers"]["x-codex-window-id"] == "agent-zero" + if client_version: + assert call["headers"]["version"] == "0.142.5" + else: + assert "version" not in call["headers"] def test_chat_messages_to_response_body_preserves_image_parts_for_responses():