Skip to content

Commit d5e8ecf

Browse files
fadi-georgeclaude
andcommitted
test: [SDK-5535] update the retry harness now that Retry-After is per operation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8f65879 commit d5e8ecf

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎examples/demo/scripts/retry/README.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ What the SDK should do:
6262
- **Backoff per operation**: after the Nth retryable failure an operation waits N × 15s
6363
(`opRepoDefaultFailRetryBackoff`), capped at 1h, with no jitter. `HttpClient` does not re-send on
6464
its own. Retryable is anything but 400, 401, 402, 403, 404, 409 and 410.
65-
- **Retry-After** is the minimum wait, capped at 1h. Foreground and network return do not cut it
66-
short. `HttpClient` also holds every later SDK request until the Retry-After window ends, so
67-
other routes pause too.
65+
- **Retry-After** is the minimum wait for that operation, capped at 1h. Foreground and network
66+
return do not cut it short. Other routes are not held. A 429 without Retry-After waits 60s.
6867
- **Other records keep going**: while one operation waits, operations on other records are sent.
6968
Operations on the same record wait behind it, so order is kept.
7069
- **Foreground and network return** end the backoff. The next attempt goes out after the queue's

‎examples/demo/scripts/retry/report.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
Expected gaps model OperationRepo's per-operation backoff:
66
- After the Nth retryable failure an operation waits N * 15s (opRepoDefaultFailRetryBackoff),
77
capped at 1h. There is no jitter and HttpClient does not re-send on its own.
8-
- Retry-After is the minimum wait, capped at 1h. An unparsable value counts as 60s.
8+
- Retry-After is the minimum wait, capped at 1h. An unparsable value, or a 429 without one,
9+
counts as 60s.
910
- The queue may wait up to opRepoExecutionInterval (5s) more if something else was enqueued
1011
during the backoff, so a few seconds of slack is allowed.
1112
A foreground or network return ends the backoff early (but not Retry-After), so short gaps right
@@ -33,8 +34,10 @@ def route_key(entry):
3334
return f"{entry['method']} {path}"
3435

3536

36-
def backoff_window(failures, retry_after):
37+
def backoff_window(failures, status, retry_after):
3738
low = min(failures * BACKOFF_STEP, MAX_DELAY)
39+
if retry_after is None and status == 429:
40+
retry_after = RETRY_AFTER_PARSE_FAIL
3841
has_floor = retry_after is not None
3942
if has_floor:
4043
try:
@@ -95,7 +98,7 @@ def main():
9598
expected = None
9699
else:
97100
failures += 1
98-
low, high, has_floor = backoff_window(failures, entry.get("retry_after"))
101+
low, high, has_floor = backoff_window(failures, status, entry.get("retry_after"))
99102
expected = (low, high, f"backoff #{failures}" + (", Retry-After" if has_floor else ""))
100103
print("\n* = failure injected by the proxy")
101104

0 commit comments

Comments
 (0)