fix(llm): make ProviderClient.chat attempt count match MAX_RETRIES#6
Open
Arvuno wants to merge 1 commit into
Open
fix(llm): make ProviderClient.chat attempt count match MAX_RETRIES#6Arvuno wants to merge 1 commit into
Arvuno wants to merge 1 commit into
Conversation
`ProviderClient.chat` used `while retries <= MAX_RETRIES:` with `retries = 0`, so an operator setting `MAX_RETRIES=3` actually triggered four LLM calls. The final log line printed `MAX_RETRIES` rather than the attempt count, hiding the off-by-one behind a misleading number. Replace the `while` loop with `for attempt in range(1, MAX_RETRIES + 1):`. The body no longer carries a manual `retries` counter and the `last_error` variable is properly typed. The final error log now reports the actual number of attempts (`"after N attempt(s)"`) and the ProviderError that gets raised still carries status_code 502. Adds `backend/tests/test_provider_client_retry.py` with two cases: - `litellm.completion` fails once then succeeds → exactly 2 calls. - `litellm.completion` always fails → exactly MAX_RETRIES calls, the final error log contains "attempt" and no longer contains "retries".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(llm): make ProviderClient.chat attempt count match MAX_RETRIES
ProviderClient.chatusedwhile retries <= MAX_RETRIES:withretries = 0, so an operator settingMAX_RETRIES=3actually triggeredfour LLM calls. The final log line printed
MAX_RETRIESrather than theattempt count, hiding the off-by-one behind a misleading number.
Replace the
whileloop withfor attempt in range(1, MAX_RETRIES + 1):.The body no longer carries a manual
retriescounter and thelast_errorvariable is properly typed. The final error log now reportsthe actual number of attempts (
"after N attempt(s)") and theProviderError that gets raised still carries status_code 502.
Adds
backend/tests/test_provider_client_retry.pywith two cases:litellm.completionfails once then succeeds → exactly 2 calls.litellm.completionalways fails → exactly MAX_RETRIES calls, thefinal error log contains "attempt" and no longer contains "retries".