Skip to content

Commit 4f68828

Browse files
committed
fix(providers): 🐛 exempt 503 retries from usage counting
The `AntigravityProvider` was previously incrementing `_internal_attempt_count` when encountering 503 Capacity Exhausted errors. As these server-side errors do not consume API quota, their associated retries should not be tracked against usage limits.
1 parent 0af9591 commit 4f68828

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/rotator_library/providers/antigravity_provider.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4892,10 +4892,8 @@ async def _streaming_with_retry(
48924892
f"attempt {attempt + 1}/{CAPACITY_EXHAUSTED_MAX_ATTEMPTS}. "
48934893
f"Waiting {CAPACITY_EXHAUSTED_RETRY_DELAY}s..."
48944894
)
4895-
# Increment attempt count before retry (for usage tracking)
4896-
_internal_attempt_count.set(
4897-
_internal_attempt_count.get() + 1
4898-
)
4895+
# NOTE: Do NOT increment _internal_attempt_count here - 503 capacity
4896+
# exhausted errors don't consume quota, so retries are "free"
48994897
await asyncio.sleep(CAPACITY_EXHAUSTED_RETRY_DELAY)
49004898
continue
49014899
else:

0 commit comments

Comments
 (0)