Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugins/_oauth/helpers/codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion tests/test_oauth_codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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():
Expand Down