Skip to content

fix(retry): enforce overall deadline budget across attempts#93

Merged
zeevdr merged 2 commits into
mainfrom
fix/retry-deadline-budget
May 24, 2026
Merged

fix(retry): enforce overall deadline budget across attempts#93
zeevdr merged 2 commits into
mainfrom
fix/retry-deadline-budget

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 24, 2026

Summary

  • Without a shared deadline, callers with timeout=10 and max_attempts=3 could wait up to 3*(10+backoff) seconds — far exceeding the intended budget.
  • Adds total_timeout to RetryConfig so the wall-clock budget is enforced across all attempts: backoff sleeps are clipped to the remaining time, and the loop exits immediately when the budget is exhausted.

Test plan

  • test_deadline_clips_sleep — verifies sleep is clipped to remaining budget
  • test_deadline_exhausted_raises_immediately — verifies no sleep occurs when budget is gone after a failure
  • test_deadline_already_passed_before_second_attempt — verifies loop-top check halts further attempts
  • test_write_safe_config_preserves_total_timeout — verifies write_safe_config propagates the field
  • test_async_deadline_exhausted_raises_immediately — async variant of the exhausted-budget case
  • All 227 tests pass; coverage at 97.13%

Closes #58

Add `total_timeout` to `RetryConfig` so the wall-clock budget is shared
across all retry attempts. Without this, a caller with `timeout=10` and
`max_attempts=3` could wait up to `3*(10+backoff)` seconds total.

When set, backoff sleeps are clipped to the remaining budget and the
loop exits immediately when the budget is exhausted — either at the
loop-top check or when `remaining <= 0` after a failure.

`write_safe_config` propagates `total_timeout` to the derived config.

Closes #58

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr added this to the Beta Readiness milestone May 24, 2026
@zeevdr zeevdr added size: S Quick win — a few hours or less priority: P2 Nice-to-have labels May 24, 2026
Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
sdk/src/opendecree/_retry.py 90.47% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@zeevdr zeevdr merged commit f353484 into main May 24, 2026
12 checks passed
@zeevdr zeevdr deleted the fix/retry-deadline-budget branch May 24, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P2 Nice-to-have size: S Quick win — a few hours or less

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retry: enforce overall deadline budget across attempts

1 participant