Skip to content

[STALE: REBASE FROM NEW FORK] anthropic-pool: per-model-family cooldown on seven_day_<family> 429s; log limit headers on every 429 - #14

Draft
vadymhimself wants to merge 4 commits into
release/2.65.0-vadymhimself.15from
core-be-r4b/anthropic-429-family
Draft

vadymhimself wants to merge 4 commits into
release/2.65.0-vadymhimself.15from
core-be-r4b/anthropic-429-family

Conversation

@vadymhimself

Copy link
Copy Markdown
Collaborator

P1 (Harvest HQ, Andrew on Hermes): only 429s on Claude. Today any 429 cools the whole account, and the headers that say which limit refused are never logged, so the cause cannot be read from logs.

Change

  • A 429 whose anthropic-ratelimit-unified-representative-claim is seven_day_<family> and whose request model is that family (opus/sonnet/haiku/fable) cools only (account, family), until Retry-After, else the unified reset, else 60 s. The account keeps serving its other models; an Opus request returns the pool 429 only when every account is out of Opus, with that family's earliest reset as Retry-After.
  • Every other 429 (five_hour, seven_day, no claim) cools the whole account exactly as before.
  • Every 429 logs [anthropic-pool] 429 on <account> model=<id> claim=<..> status=<..> 5h=<..> 7d=<..> retry-after=<..> reset=<..> cooldown=<s>s (<source>) scope=<family|account>, including on single-account gateways with no failover pool (cooldown=none (no failover pool)). No credential is in these headers.
  • The no-other-account line says no other eligible Anthropic OAuth account; returning 429 (others=N cooled=N reauth=N unusable=N) instead of claiming every account is in cooldown.
  • route.modelId is passed from the 3 rotate callers and the 2 pool-selection callers.

Test: tests/adapters/anthropic/anthropic-ratelimit-headers.test.ts, "a model-scoped weekly 429 cools only that model family" (Opus cooled per account, Sonnet still routes, pool 429 Retry-After = family reset, clear removes family entries, five_hour on Opus still cools the account, exact log line). Local: tsc --noEmit clean, 183/183 across the 5 pool/failover test files (lane witness VOID on git ENOBUFS in this repo, so CI is the owner run).

Eval added/updated: N/A deterministic (unit test: tests/adapters/anthropic/anthropic-ratelimit-headers.test.ts)

🤖 Generated with Claude Code

… log limit headers on every 429

A 429 whose representative claim is seven_day_<family> (e.g. seven_day_opus) for a request of that
family now cools only (account, family): the account keeps serving its other models, and an Opus
request is refused only when every account is out of Opus. Every other 429 still cools the whole
account. Each 429 logs model, representative-claim, unified/5h/7d status, retry-after, reset and the
chosen cooldown, and the no-eligible-account line now counts cooled, re-auth and unusable accounts
instead of claiming they are all in cooldown.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 10, 2026
Co-Authored-By: Claude Code <noreply@anthropic.com>
@github-actions github-actions Bot changed the title anthropic-pool: per-model-family cooldown on seven_day_<family> 429s; log limit headers on every 429 [WRONG BRANCH] anthropic-pool: per-model-family cooldown on seven_day_<family> 429s; log limit headers on every 429 Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (release/2.65.0-vadymhimself.15); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft November 10, 2026 14:24
vadymhimself and others added 2 commits November 10, 2026 22:25
…nd the cooldown end on each 429

Co-Authored-By: Claude Code <noreply@anthropic.com>
…line

The 429 log line now prints on every 429 (pinned included), so the pin e2e
counts the '; failing over to' line that only a real account switch prints.

Co-Authored-By: Claude Code <noreply@anthropic.com>
vadymhimself added a commit that referenced this pull request Nov 10, 2026
…quest-shape 429 no longer cools the account (+ #14, .18) (#15)

* fix(anthropic-pool): cool a model-scoped weekly 429 per model family, log limit headers on every 429

A 429 whose representative claim is seven_day_<family> (e.g. seven_day_opus) for a request of that
family now cools only (account, family): the account keeps serving its other models, and an Opus
request is refused only when every account is out of Opus. Every other 429 still cools the whole
account. Each 429 logs model, representative-claim, unified/5h/7d status, retry-after, reset and the
chosen cooldown, and the no-eligible-account line now counts cooled, re-auth and unusable accounts
instead of claiming they are all in cooldown.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* chore(release): 2.65.0-vadymhimself.18

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(anthropic-pool): log every anthropic-ratelimit-unified-* header and the cooldown end on each 429

Co-Authored-By: Claude Code <noreply@anthropic.com>

* test(pin): count only real 429 failovers, not the per-429 diagnostic line

The 429 log line now prints on every 429 (pinned included), so the pin e2e
counts the '; failing over to' line that only a real account switch prints.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(anthropic): give an OAuth source replay the Claude identity system block

A replayed Anthropic Messages body from a non-Claude-Code client (Hermes) reached
the subscription endpoint with only its own system prompt. The translated path
always prepends the identity block; the replay path did not. Prepend it on OAuth
when no system block already carries a Claude Code or Agent SDK identity line,
so Claude Code bodies (identity after the billing-header block) are not doubled.
Replay test sources that stand for Claude Code now carry its identity line.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(anthropic-pool): a request-shape 429 fails only the request, never cools the account

An account is cooled (and the request fails over) only on a real limit: a unified window
marked rejected, or a Retry-After when Anthropic sent no unified status. A 429 whose
unified status is still "allowed", or with no limit evidence, is a refusal of this request's
shape (e.g. a replay without the Claude Code identity); before, it benched every client on
the account. Also moves prependClaudeIdentity next to the identity constant in
src/oauth/anthropic.ts so src/adapters/anthropic.ts stays within its file-size cap.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* Cool on a 429 with no unified status, as before

Only a 429 whose unified status is present and says allowed skips the cooldown;
a header-less 429 keeps the legacy cooldown and failover the routing tests expect.

Co-Authored-By: Claude Code <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
@vadymhimself vadymhimself changed the title [WRONG BRANCH] anthropic-pool: per-model-family cooldown on seven_day_<family> 429s; log limit headers on every 429 [STALE: REBASE FROM NEW FORK] anthropic-pool: per-model-family cooldown on seven_day_<family> 429s; log limit headers on every 429 Nov 18, 2026
@vadymhimself

Copy link
Copy Markdown
Collaborator Author

This PR is based on the superseded 2.65 gateway line. Rebuild the change from port/ar-on-upstream-2026-11-18 (upstream-derived 2.100 AR overlay, PR #46): #46 . Do not rebase onto or merge the old release line. Preserve the new gateway quota/cache gate and re-run the affected regressions. The candidate is not deployed; do not publish or replace a running gateway without explicit approval.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant