Retry a Failed Model Call
Implement call_with_retry(fn, max_attempts=3, base_delay=1.0). Call fn() and return its result. If it raises:
- Retry
RateLimitError,TimeoutErrorandServerError. - Do not retry anything else. A
ValueErrorwill fail the same way forever. - Wait
base_delay * (2 ** attempt)before each retry (1s, 2s, 4s), using the providedsleep()rather thantime.sleep, so the tests don't actually wait. - After
max_attemptstotal attempts, re-raise the last exception.