Skip to content

fix(quota): parse absolute ISO datetime reset timestamps in weekly quota fallback - #11353

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.50from
sprintberlin:fix/quota-iso-datetime-reset
Aug 24, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.50from
sprintberlin:fix/quota-iso-datetime-reset

Conversation

@sprintberlin

Copy link
Copy Markdown
Contributor

Summary

Fixes #11352.

Parses full absolute ISO datetimes (YYYY-MM-DD[T ]HH:MM[:SS]) in parseDayGranularityResetMs / buildWeeklyQuotaFallback, so weekly/monthly quota exhaustion signals from upstreams like Z.AI (GLM) receive the actual multi-day cooldown reported by the provider instead of falling back to the 24h default.

Root Cause

buildWeeklyQuotaFallback called parseDayGranularityResetMs(), which only recognized reset in N days. When the upstream provided a full datetime such as Your limit will reset at 2026-08-29 21:01:21, parsing yielded null and fell back to WEEKLY_QUOTA_COOLDOWN_MS = 24h. The connection was retried every 24 hours until the true weekly reset.

Implementation

  • Added parseIsoDateTimeResetMs in open-sse/services/quotaResetParsing.ts, parsing YYYY-MM-DD[T ]HH:MM[:SS] with optional Z/±HH:MM offset and UTC fallback for naive datetimes.
  • Delegated from parseDayGranularityResetMs to parseIsoDateTimeResetMs before parseMonthDayResetMs.
  • Updated buildWeeklyQuotaFallback in open-sse/services/quotaTextCooldowns.ts to use the parsed reset duration when available.

Tests & Verification

  • node --import tsx/esm --test tests/unit/repro-glm-iso-reset-24h-cap.test.ts (12/12 pass)
  • node --import tsx/esm --test tests/unit/ollama-cloud-weekly-quota-cooldown-3709.test.ts (6/6 pass)

@diegosouzapw
diegosouzapw merged commit e1c2b34 into cheaper-inference:release/v3.8.50 Aug 24, 2026
3 checks passed
diegosouzapw added a commit that referenced this pull request Aug 25, 2026
…n test

The #11353 regression test pins an ABSOLUTE upstream reset instant
(2026-08-29 21:01:21) in its production fixture body but measured the
resulting cooldown against the real wall clock. The remaining window
therefore shrank every day: from 2026-08-25 it dropped under the
5-day floor the two assertions use, and past 2026-08-29 it would
parse to null and collapse onto the 24h WEEKLY_QUOTA_COOLDOWN_MS
default - a guaranteed future red.

The shipped parser (parseIsoDateTimeResetMs / parseDayGranularityResetMs
/ buildWeeklyQuotaFallback / checkFallbackError) is correct: it returned
the real multi-day reset, just measured from today instead of the
fixtures NOW. Freeze Date at NOW via node:test mock timers in the two
time-dependent cases so they assert the parser rather than the calendar.
No assertion weakened, no production code touched.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ota fallback (cheaper-inference#11353)

Merged via consolidated batch validation. Fixes GLM/Z.AI weekly quota fallback: parseDayGranularityResetMs only recognized 'reset in N days', dropping the real multi-day cooldown when upstream returns a full absolute ISO datetime. Own repro test passes.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…n test

The cheaper-inference#11353 regression test pins an ABSOLUTE upstream reset instant
(2026-08-29 21:01:21) in its production fixture body but measured the
resulting cooldown against the real wall clock. The remaining window
therefore shrank every day: from 2026-08-25 it dropped under the
5-day floor the two assertions use, and past 2026-08-29 it would
parse to null and collapse onto the 24h WEEKLY_QUOTA_COOLDOWN_MS
default - a guaranteed future red.

The shipped parser (parseIsoDateTimeResetMs / parseDayGranularityResetMs
/ buildWeeklyQuotaFallback / checkFallbackError) is correct: it returned
the real multi-day reset, just measured from today instead of the
fixtures NOW. Freeze Date at NOW via node:test mock timers in the two
time-dependent cases so they assert the parser rather than the calendar.
No assertion weakened, no production code touched.
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.

fix(quota): weekly quota with full ISO datetime reset is capped at 24h instead of the upstream reset

2 participants