Skip to content

Commit 20647ab

Browse files
samxu01claude
andcommitted
fix(litellm): only signal codex-account rotation on codex 429s
The rate-limit signaler wrote /chatgpt-auth/rotate-now on ANY 429, including Nemotron's (the codex fallback). When codex was down and everything fell back to Nemotron, Nemotron's load 429s thrashed the rotator's active-account pointer and churned refresh_tokens — pointless, since rotating the codex account pool can't relieve a Nemotron rate limit. Gate the signal on codex/chatgpt models so only a real codex 429 triggers rotation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7126c35 commit 20647ab

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

k8s/helm/commonly/templates/agents/litellm-deployment.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ spec:
107107
'ratelimiterror',
108108
))
109109
110+
def _is_codex_model(model: str) -> bool:
111+
# Only codex rotates the ChatGPT account pool. Nemotron (the codex
112+
# fallback) and every other provider also throw 429s under load, but
113+
# rotating codex accounts can't help them — it only thrashes the
114+
# active-account pointer and burns refresh_tokens. Codex surfaces as
115+
# 'openai-codex/*' (public alias) or 'chatgpt/*' (litellm_params.model).
116+
m = (model or '').lower()
117+
return 'codex' in m or 'chatgpt' in m
118+
110119
def _write_signal(model: str, exc_str: str):
111120
try:
112121
tmp = SIGNAL_FILE + '.tmp'
@@ -132,8 +141,9 @@ spec:
132141
exc = kwargs.get('exception')
133142
if not exc: return
134143
exc_str = str(exc)
135-
if _is_rate_limit(exc_str):
136-
_write_signal(kwargs.get('model', 'unknown'), exc_str)
144+
model = kwargs.get('model', 'unknown')
145+
if _is_rate_limit(exc_str) and _is_codex_model(model):
146+
_write_signal(model, exc_str)
137147
138148
async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):
139149
pass
@@ -142,8 +152,9 @@ spec:
142152
exc = kwargs.get('exception')
143153
if not exc: return
144154
exc_str = str(exc)
145-
if _is_rate_limit(exc_str):
146-
_write_signal(kwargs.get('model', 'unknown'), exc_str)
155+
model = kwargs.get('model', 'unknown')
156+
if _is_rate_limit(exc_str) and _is_codex_model(model):
157+
_write_signal(model, exc_str)
147158
148159
proxy_handler_instance = RateLimitSignaler()
149160
PYEOF

0 commit comments

Comments
 (0)