diff --git a/codex-launcher_2.2.1_all.deb b/codex-launcher_2.2.1_all.deb index 873bdb5..f04d7df 100644 Binary files a/codex-launcher_2.2.1_all.deb and b/codex-launcher_2.2.1_all.deb differ diff --git a/src/translate-proxy.py b/src/translate-proxy.py index 0833843..eff1a26 100755 --- a/src/translate-proxy.py +++ b/src/translate-proxy.py @@ -918,12 +918,11 @@ class Handler(http.server.BaseHTTPRequestHandler): _crof_debug_path = os.path.join(_LOG_DIR, "crof-upstream.jsonl") with open(_crof_debug_path, "a") as _cdf: _cdf.write(json.dumps({ - "ts": _ts, "model": model, "max_tokens": chat_body.get("max_tokens"), - "reasoning_enabled": REASONING_ENABLED, "reasoning_effort": chat_body.get("reasoning_effort"), + "model": model, "max_tokens": chat_body.get("max_tokens"), + "reasoning_effort": chat_body.get("reasoning_effort"), "enable_thinking": chat_body.get("enable_thinking", "NOT_SENT"), "n_messages": len(chat_body.get("messages", [])), "has_tools": bool(chat_body.get("tools")), - "messages_summary": [{"role": m.get("role"), "tc": len(m.get("tool_calls", [])), "content_len": len(str(m.get("content", "")))[:6], "tool_call_id": m.get("tool_call_id")} for m in chat_body.get("messages", [])], }) + "\n") req = urllib.request.Request( target, @@ -1098,19 +1097,22 @@ class Handler(http.server.BaseHTTPRequestHandler): last_resp_id = None last_output = None last_status = None - for event in stream_fn(upstream): - self.wfile.write(event.encode("utf-8")) - self.wfile.flush() - for line in event.strip().split("\n"): - if line.startswith("data: "): - try: - d = json.loads(line[6:]) - if d.get("type") == "response.completed": - last_resp_id = d.get("response", {}).get("id") - last_output = d.get("response", {}).get("output", []) - last_status = d.get("response", {}).get("status") - except: pass - _log_resp(last_resp_id, last_status, last_output) + try: + for event in stream_fn(upstream): + self.wfile.write(event.encode("utf-8")) + self.wfile.flush() + for line in event.strip().split("\n"): + if line.startswith("data: "): + try: + d = json.loads(line[6:]) + if d.get("type") == "response.completed": + last_resp_id = d.get("response", {}).get("id") + last_output = d.get("response", {}).get("output", []) + last_status = d.get("response", {}).get("status") + except: pass + except (ConnectionResetError, BrokenPipeError, ConnectionAbortedError): + print("[translate-proxy] client disconnected during stream", file=sys.stderr) + _log_resp(last_resp_id, last_status or "client_disconnect", last_output) if last_resp_id and input_data is not None: store_response(last_resp_id, input_data, last_output) else: