This commit is contained in:
null 2026-05-26 14:38:01 -05:00
parent 2d40ae0d63
commit d65e888ade
1 changed files with 6 additions and 7 deletions

View File

@ -58,12 +58,11 @@ from app.core.time import utcnow
logger = get_logger(__name__)
CACHE_TTL_SECONDS = 60
# Anthropic's subscription endpoint rate-limit window is ~30-60s. Retrying
# sooner than that (old 5s value) creates a tight retry loop that keeps the
# rate limit permanently throttled. Use the same 60s TTL as successes so the
# next auto-poll only fires after the window has cleared. Manual refreshes
# (force_refresh=True) always bypass this TTL.
CACHE_TTL_FAILURE_SECONDS = 60
# Anthropic's oauth/usage endpoint requires User-Agent: claude-code/<ver> and
# enforces a ~180s poll floor — callers without the correct UA hit an aggressive
# bucket that 429s indefinitely. Keep the failure TTL at 180s so we never
# retry faster than that floor. Manual refreshes (force_refresh=True) bypass.
CACHE_TTL_FAILURE_SECONDS = 180
STALE_SUBSCRIPTION_TTL_SECONDS = 10 * 60
REQUEST_TIMEOUT = 8.0 # seconds
@ -768,7 +767,7 @@ async def _fetch_anthropic_subscription(session_key: str) -> list[SubscriptionWi
"""
headers = {
"Authorization": f"Bearer {session_key}",
"User-Agent": "pipeline",
"User-Agent": "claude-code/1.0.0",
"Accept": "application/json",
"anthropic-version": "2023-06-01",
"anthropic-beta": "oauth-2025-04-20",