Skip to content

fix: preserve float values in retry backoff config#30

Merged
steve-calvert-glean merged 1 commit intomainfrom
fix/chk-002-retry-float
Mar 24, 2026
Merged

fix: preserve float values in retry backoff config#30
steve-calvert-glean merged 1 commit intomainfrom
fix/chk-002-retry-float

Conversation

@steve-calvert-glean
Copy link
Contributor

Summary

  • Removes int() truncation in _build_retry_config() that silently corrupted sub-second values
  • GLEAN_RETRY_INITIAL=0.5 now correctly rounds to 1 instead of truncating to 0
  • Also removes unused import re (dead code)

Root Cause

initial_interval = int(initial) truncates any float < 1.0 to zero, disabling the initial backoff. BackoffStrategy requires int types, so round() is used to preserve intent (0.5 → 1, not 0).

Fixes

CHK-002 from EVAL-CHECKLIST.md (also cleans up CHK-028)

Test plan

  • uv run pytest tests/ -x -q passes
  • Setting GLEAN_RETRY_INITIAL=0.5 results in a non-zero interval

@steve-calvert-glean steve-calvert-glean requested a review from a team as a code owner March 21, 2026 23:41
Copy link
Contributor Author

@steve-calvert-glean steve-calvert-glean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — CHK-002

Acceptance Criteria Met

  • int() truncation is removed from all three variables: initial_interval, max_interval, max_elapsed_time
  • round() is used in place of int() — this is the correct choice per the acceptance criteria
  • The dead import re is removed (also cleans up CHK-028 as noted in the PR)
  • Change is minimal and focused — only _common.py is modified

Issues Found

  • round() still converts floats to ints, which means the fix is a behavior improvement (0.5 rounds to 1 instead of truncating to 0) but does not fully "preserve" float values as the PR title says. This is fine if BackoffStrategy requires int types — the PR description acknowledges this: "BackoffStrategy requires int types, so round() is used to preserve intent". Confirm that BackoffStrategy.initial_interval, max_interval, and max_elapsed_time are typed as int in the SDK; if they accept float directly, round() is still safe but the comment in the description would need updating.
  • The exponent field is correctly left as a float (passed directly to BackoffStrategy), confirming the SDK does accept floats for at least one field. This inconsistency in the SDK's type surface is worth a comment in the code so future maintainers don't wonder why exponent is float while the others use round().
  • _parse_retry_env_int (lines 68-75 of _common.py) is now dead code — nothing calls it after this change. It's not a blocker, but it's orphaned and should be removed in a follow-up.

Suggestions

  • Add a brief inline comment near the round() calls explaining why: # BackoffStrategy requires int; round() preserves intent (e.g. 0.5 → 1, not 0)
  • Track removal of _parse_retry_env_int as a follow-up cleanup item.

Verdict: Ready to merge

@steve-calvert-glean steve-calvert-glean force-pushed the fix/chk-002-retry-float branch 2 times, most recently from 2532135 to 06818e2 Compare March 24, 2026 02:36
…CHK-002)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@steve-calvert-glean steve-calvert-glean merged commit b7d33b4 into main Mar 24, 2026
1 of 5 checks passed
@steve-calvert-glean steve-calvert-glean deleted the fix/chk-002-retry-float branch March 24, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants