Spec retries for a flaky SMS provider client

Vibe codingMedium25 min

Your task

Your Python service sends login codes and appointment reminders through a third-party SMS API. The provider times out a few times an hour and went down twice this quarter. During the last outage, a hand-written retry loop sent some customers the same reminder 5 times. An agent will write a new client with retries.

Write the spec you would hand the agent.

What you know:

  • Python 3.12 and httpx
  • POST /v1/messages sends a message, and the provider honors an Idempotency-Key header for 24 hours
  • over 50 requests a second, the provider returns 429 with a Retry-After header
  • the login screen waits for its code, while reminders go out from a job queue that retries failed jobs

Then, in a few sentences: what does "add retries with backoff" usually get wrong?