Skip to content

fix(llm): enforce max_retries cap on the unbounded retry loop#165

Open
lfnothias wants to merge 1 commit into
mimosa_v2from
feat/bounded-retry
Open

fix(llm): enforce max_retries cap on the unbounded retry loop#165
lfnothias wants to merge 1 commit into
mimosa_v2from
feat/bounded-retry

Conversation

@lfnothias

@lfnothias lfnothias commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Change

LLMProvider.__call__ retries in a while True loop. self.max_retries is set in __init__ but never read, so a persistently failing provider (timeout, overload, rate limit) retries indefinitely, re-sending the full prompt each time — unbounded latency, and unbounded spend where partial output is billed. Both retryable paths now raise once the attempts reach self.max_retries. The context-window path keeps its own independent cap.

Not changed

max_retries stays at 3. The success path and non-retryable errors are unaffected; a non-retryable error is still raised on the first attempt. The only change in behaviour is that a call which previously could not terminate now does.

Tests

tests/llm_provider_test.py: a persistent retryable error and repeated timeouts each raise after max_retries + 1 attempts; a non-retryable error raises on the first attempt. The network call and the sleep are mocked. Full suite: 198 passed, 4 skipped.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant