Skip to content

feature: unit tests for generic_call_api_with_retries retry/backoff paths - #44

Open
giladsamuels-cognition wants to merge 1 commit into
mainfrom
devin/1789733196-test-retry-driver
Open

giladsamuels-cognition wants to merge 1 commit into
mainfrom
devin/1789733196-test-retry-driver

Conversation

@giladsamuels-cognition

@giladsamuels-cognition giladsamuels-cognition commented Sep 18, 2026 •

Copy link
Copy Markdown

Summary

generic_call_api_with_retries — the retry layer every LLM call funnels through — had no direct tests. Adds mocked, network-free tests in tests/llm/test_llm_utils.py covering each branch of the driver:

  • retriable: rate_limit_exceptions, and api_error_exceptions whose status is 429 or >= 500
  • non-retriable: status 400/401/404/None, unexpected exception types (re-raised on the first attempt, no sleep), and a get_status_code_fn that itself raises (status stays None, so the error is re-raised)
  • invalid response content retried until valid, and RuntimeError after exhausting max_retries

Backoff is locked in by recording delays via a recorded_sleeps fixture that monkeypatches llm_utils.time.sleep, pinning both formulas (with initial=2, max=10):

exception-driven retry at attempt n -> min(initial * 2**n,     max)   # [4, 8, 10]
invalid-content retry at attempt n  -> min(initial * 2**(n-1), max)   # [2, 4, 8]

No production code changed.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/547e3f16ea034219bcae56fec5263cbd
Open in Devin Desktop: https://app.devin.ai/desktop/session/547e3f16ea034219bcae56fec5263cbd?variant=devin
Requested by: @giladsamuels-cognition


Devin Review

…ff paths

Co-Authored-By: Gilad Samuels <gilad.samuels@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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