A rate limit is the most common transient failure an agent meets: the model provider returns a 429, and the run fails even though nothing is wrong with the task. The pattern from the n8n error-handling guides is to treat a 429 specially: sleep for a growing delay, then retry the agent, up to three attempts, and only then alert a person with a fallback response. Read the delay from the error when the provider gives one; when it does not, start with sixty seconds and double it. Do not retry immediately: an instant retry hits the same limit.
What you need
- An agent run that has hit a 429 rate limit before
- A sleep or wait step you can place before the retry
- A fallback response to use if the retries are spent
Step 1: Catch the 429 and read its delay
Branch on the error: when it is a 429, read the retry delay from the error message or headers when present. Other errors take a different path.
Step 2: Wait, then retry the run up to three times
Sleep for the delay, then retry the agent run. Double the wait on each further attempt, and stop after three attempts.
Step 3: Fall back and alert when the retries are spent
If the third attempt still hits the limit, stop retrying, return the fallback response, and alert a person with the workflow name and the error. A fourth silent retry is just a loop.
Worked example: synthetic rate-limit retry
The table below is a synthetic example. It shows the expected result of the rate-limit retry; no agent was run.
| Attempt | Wait before it | Result |
|---|---|---|
| First run | None | 429 |
| Retry 1 | 60 seconds | 429 |
| Retry 2 | 120 seconds | Success |
| Retries spent | n/a | Fallback + alert |
Expected result (UNTESTED). the run retries after a growing wait and succeeds on the second retry, and a run that stays limited falls back and alerts. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- An instant retry hits the same rate limit, so always wait first.
- Three retries is a starting point; a provider with a long limit may need a queue instead.
- A fallback response must be marked as a fallback, or it will be used as a real answer.
- Rate limits are per provider, so a retry that switches models may work where waiting would not.
