From 2cb4ad0d8d2e4f7c81ff8478a6bc222b457ae3fd Mon Sep 17 00:00:00 2001 From: Liang Jiaqing Date: Thu, 11 Jun 2026 21:58:44 +0800 Subject: [PATCH] fix responses codex client metadata --- llmcore.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llmcore.py b/llmcore.py index 1e3de56f..6e6b7f19 100644 --- a/llmcore.py +++ b/llmcore.py @@ -1,7 +1,7 @@ import os, json, re, time, requests, sys, threading, urllib3, base64, importlib, uuid, pathlib from datetime import datetime urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) -_RESP_CACHE_KEY = str(uuid.uuid4()) +_RESP_CACHE_KEY = str(uuid.uuid4()); _RESP_CODEX_KEY = str(uuid.uuid4()) _ROOT = os.path.dirname(os.path.abspath(__file__)) if _ROOT not in sys.path: sys.path.append(_ROOT) @@ -408,7 +408,8 @@ def _openai_stream(sess, messages): if api_mode == "responses": url = auto_make_url(sess.api_base, "responses") payload = {"model": model, "input": _to_responses_input(messages), "stream": sess.stream, - "prompt_cache_key": _RESP_CACHE_KEY, "instructions": sess.system or "You are an Omnipotent Executor."} + "prompt_cache_key": _RESP_CACHE_KEY, "instructions": sess.system or "You are an Omnipotent Executor.", + "client_metadata": {"x-codex-window-id": f"{_RESP_CACHE_KEY}:0","x-codex-installation-id": _RESP_CODEX_KEY}} if sess.reasoning_effort: payload["reasoning"] = {"effort": sess.reasoning_effort} if sess.max_tokens: payload["max_output_tokens"] = sess.max_tokens else: @@ -739,7 +740,7 @@ class NativeClaudeSession(BaseSession): return MockResponse(thinking, content, tool_calls, str(content_blocks)) class NativeOAISession(NativeClaudeSession): - native_ua = "codex_cli_rs/0.139.0 (Windows 10.0.26200; x86_64) unknown" + native_ua = "codex_exec/0.139.0 (Windows 10.0.26200; x86_64) unknown (codex_exec; 0.139.0)" def raw_ask(self, messages): messages = _fix_messages(messages) messages = _ensure_thinking_blocks(messages, self.model)