Skip to content

Commit a9295df

Browse files
dmikushinclaude
andcommitted
fix(free-code provider): increase retry count and backoff window for 429s
Rate-limit retries were too aggressive (3 attempts, max 8s wait). Since the free-code proxy's x-app: cli fix may not be deployed everywhere yet, the repowise client now retries up to 6 times with exponential backoff up to 60 seconds, covering sustained rate-limit windows. Also adds before_sleep_log so retry attempts are visible in logs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 59c95b7 commit a9295df

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

packages/core/src/repowise/core/providers/llm/free_code.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
retry_if_exception_type,
3030
stop_after_attempt,
3131
wait_exponential_jitter,
32+
before_sleep_log,
3233
RetryError,
3334
)
35+
import logging
3436

3537
from repowise.core.providers.llm.base import (
3638
BaseProvider,
@@ -46,9 +48,13 @@
4648

4749
log = structlog.get_logger(__name__)
4850

49-
_MAX_RETRIES = 3
50-
_MIN_WAIT = 1.0
51-
_MAX_WAIT = 8.0
51+
# More aggressive retry settings than other providers: the free-code proxy
52+
# inherits Claude Code's rate-limit tier only when x-app: cli is present
53+
# (fixed in free-code serve). Until old binaries are updated, the client
54+
# retries longer to absorb transient 429s.
55+
_MAX_RETRIES = 6
56+
_MIN_WAIT = 2.0
57+
_MAX_WAIT = 60.0 # rate-limit backoffs can be long; wait up to 1 minute
5258

5359
_DEFAULT_BASE_URL = "http://localhost:3180"
5460

@@ -136,6 +142,7 @@ async def generate(
136142
retry=retry_if_exception_type(ProviderError),
137143
stop=stop_after_attempt(_MAX_RETRIES),
138144
wait=wait_exponential_jitter(initial=_MIN_WAIT, max=_MAX_WAIT),
145+
before_sleep=before_sleep_log(logging.getLogger(__name__), logging.WARNING),
139146
reraise=True,
140147
)
141148
async def _generate_with_retry(

0 commit comments

Comments
 (0)