Skip to content

fix: measure provider request spacing with a monotonic clock - #80

Open
Afloat16 wants to merge 1 commit into
billion-token-one-task:masterfrom
Afloat16:fix/provider-rate-monotonic-clock-20261202-r2
Open

Afloat16 wants to merge 1 commit into
billion-token-one-task:masterfrom
Afloat16:fix/provider-rate-monotonic-clock-20261202-r2

Conversation

@Afloat16

@Afloat16 Afloat16 commented Dec 2, 2026

Copy link
Copy Markdown

Problem

Provider rate limiting measures elapsed time with the wall clock. Clock corrections can turn the next request's one-second interval into an hour-long sleep, or skip the rate interval entirely. This can stall the research workers or create a burst of requests after a clock adjustment.

Changes

Use time.monotonic() for in-process request spacing and an explicit unset timestamp for the first request. The existing per-provider lock, configured RPM, and persistent cooldown behavior remain unchanged.

Validation

Deterministic clock tests exercise both backward and forward wall-clock jumps, a first request at monotonic time zero, and an interval that has already elapsed.

  • Base regression result: 2 failed, 1 passed.
  • python -m pytest -q tests/test_provider_rate_clock.py tests/test_llm_client.py: 27 passed.

@cla-assistant

cla-assistant Bot commented Dec 2, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Dec 2, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

1 participant