From cbf5bd7fc967b300f02326ec918184907f626779 Mon Sep 17 00:00:00 2001 From: Roman | RyzenAdvanced Date: Tue, 26 May 2026 00:11:07 +0400 Subject: [PATCH] =?UTF-8?q?feat:=20hybrid=20endpoint=20fallback=20?= =?UTF-8?q?=E2=80=94=20try=20cloudcode-pa=20+=20daily-cloudcode-pa=20on=20?= =?UTF-8?q?429?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/translate-proxy.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/translate-proxy.py b/src/translate-proxy.py index 0d8bf07..f1a4004 100755 --- a/src/translate-proxy.py +++ b/src/translate-proxy.py @@ -5071,7 +5071,10 @@ class Handler(http.server.BaseHTTPRequestHandler): _allow_staging = os.environ.get("ALLOW_ANTIGRAVITY_STAGING", "0") == "1" if OAUTH_PROVIDER == "google-antigravity": - _antigravity_endpoints = ["https://cloudcode-pa.googleapis.com"] + _antigravity_endpoints = [ + "https://cloudcode-pa.googleapis.com", + "https://daily-cloudcode-pa.googleapis.com", + ] if _allow_staging: _antigravity_endpoints.extend([ "https://daily-cloudcode-pa.sandbox.googleapis.com", @@ -5128,14 +5131,16 @@ class Handler(http.server.BaseHTTPRequestHandler): if e.code == 403 and "SERVICE_DISABLED" in err_body[:500] and ep != endpoints[-1]: print(f"[{self._session_id}] {ep} SERVICE_DISABLED, trying next endpoint", file=sys.stderr) continue - if e.code == 429 and ep != endpoints[-1] and _allow_staging: - print(f"[{self._session_id}] {ep} HTTP 429, trying next endpoint", file=sys.stderr) - continue - if e.code == 429: + if e.code == 429 and OAUTH_PROVIDER.startswith("google"): + print(f"[{self._session_id}] 429 from {ep}, body: {err_body[:300]}", file=sys.stderr) + if ep != endpoints[-1]: + print(f"[{self._session_id}] {ep} HTTP 429, trying fallback endpoint", file=sys.stderr) + continue pool = _google_antigravity_pool if OAUTH_PROVIDER == "google-antigravity" else _google_cli_pool _, acct = _get_google_account(OAUTH_PROVIDER) if acct: pool.mark_rate_limited(acct, 60) + print(f"[{self._session_id}] all endpoints returned 429", file=sys.stderr) return self.send_json(e.code, {"error": {"type": "upstream_error", "message": _sanitize_err_body(err_body)}}) except Exception as e: if ep == endpoints[-1]: