Building with AILesson 7 of 80

Module 1 · The call underneath everything

Errors, retries, and how a retry loop takes down your own service

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 7 of 10 in this chapter

This chapter’s goalSend the same request to a hosted model and to a model running on your own machine, read every field of the response including token counts and stop reason, and predict within a factor of two what a proposed feature will cost per thousand users before you write it.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
How a retry loop turns slow into downThe providerslows downSupposerequests thattook twoseconds nowtake twenty.Yourten-secondtimeoutfiresThe firstrequest maystill berunning. Itsoutcome needschecking.Retries addoverlappingworkMoresimultaneousattempts canexhaustavailablecapacity.You crossyour ownrate limitApplicationor providerlimits mayrejectadditionalwork.The loopretries the429sAn attemptcounter withno deadlinekeepsspending therequest’sbudget.Your serviceis downTheapplicationmay failunderamplifiedload.A hypothetical slowdown can amplify load if new attempts overlap uncertain earlier requests.Concurrency limits, a retry budget and a circuit breaker address different parts of the failure chain.
A hypothetical slowdown can amplify load if new attempts overlap uncertain earlier requests. Concurrency limits, a retry budget and a circuit breaker address different parts of the failure chain.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

Decide whether another attempt can help

Inspect the provider’s documented status and error body. Correct an invalid request or permission problem before sending it again. A rate limit or temporary server error may justify a bounded later attempt. A timeout or broken connection can leave the first request’s outcome uncertain.

For the Claude Python SDK, automatic retries are enabled by default for selected failures. When you implement an outer retry loop, disable SDK retries so the two policies do not multiply attempts. The example below retries only the selected HTTP status failures. It lets connection and timeout exceptions reach the caller for an explicit decision. SDK retries and errors.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘Errors, retries, and how a retry loop takes down your own service’, in Building with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-with-ai/retries-that-do-not-make-it-worse (Accessed: 29 November 2026).