Commit Graph
2 Commits
Author SHA1 Message Date
yetone af0558e6d0 gateway: a 429 that says in words when it's back rests until then, in Chinese as in English (#1669, Natsumeretsu)
WorkBuddy answers a frequency limit with the time it resets, in words:
"将在 2026-10-11 20:16:02 UTC+8重置" and "your usage will reset at
2026-10-11 12:37:53 UTC+8, ...". resetsAt read neither (only Claude
Code's "limit reached|<unix>" and ChatGPT's resets_at), so the Chinese
one rested quotaRest (15 min, matched 用量) and the English one
fallbackCooldown (1 min, no word list matched): the account was asked
again long before it was back, refused, and benched again.

- resetsWritten reads a time beside the reset phrasing (resetsWhen:
  "reset(s) at", 将在/将于), in the UTC/GMT offset it is written with.
  The offset must be followed by 重置 or punctuation, so a refusal cut
  after "UTC" or "UTC+" is never read as UTC; a date that isn't real,
  one past, or more than a week off (longestWritten) isn't read; another
  vendor's date in passing ("deprecated on ...", "retry after ...") is no
  reset. resetsAt falls back to it, so keepRetry notes it too.
- failure reads such a 429 as out of quota in either language.
- One that points to the account's other models ("切换其他模型",
  "switch to the other models") rests that model alone (restID), so
  the account's other models are still asked during an hours-long rest.
- rateRest: a reset time the refusal names (resetsAt, or as keepRetry
  noted it) is believed up to longestQuota, as the quota branch does,
  and the trace says "resets"; a Retry-After or rate-limit reset header
  stays held to longestWait. Decided: the stated time is the vendor's
  statement of when the account is back, and how far it is believed
  shouldn't hang on which word list the message happened to match
  (8 days as quota vs 1 hour as rate for the same words); a Retry-After
  is generic advice and keeps the hour.

The rest is the gateway's, so it holds for moved WorkBuddy users too:
the plugin (packages/workbuddy 0.1.14, explained()) passes a 429 that
isn't "unapproved channel"/14018 on as it came.
TestPluginWrittenResetRests shows a plugin-served 429 with the
reporter's refusal resting the model until the stated time.

Tests: TestResetsWritten (reporter's bytes in both languages, other
offsets, cut-short, garbled, past, >7 days, other vendors' dates),
TestWrittenResetRestsUntilThen (both languages rest the model by
"resets", noted path, cut-short falls back, other vendors' 429s
unchanged), TestRateLimitBelievesItsReset, TestPluginWrittenResetRests.
Broke each piece by hand (reader, classification, rate cap, model
scope, offset, the terminator) and each made one of them fail.
TestRateLimitBacksOffWhenItComesBack now expects "resets" for a noted
reset. go test -tags nogui ./... under a temp HOME, rebased
on 498b77fbc, passes but internal/provider's
TestCopilotSecretToolUsername, which this doesn't touch: it is #1627
(5s secret-tool bound under load) and fails alone 3 of 5 on this head
too. internal/gateway rerun after rebasing on 6ebe481f8; gofmt -l, go
vet for darwin, GOOS=linux and GOOS=windows on internal/gateway.
Not tried against WorkBuddy itself: its raw 429 JSON shape isn't
known beyond the message (err_type 6004), and a body that escapes the
Chinese as \uXXXX wouldn't be read (the reporter's classification by
用量 shows theirs isn't escaped).
2026-10-12 03:23:27 +08:00
yetone 4c7788424c gateway: a rate limit that comes back as soon as its rest is over rests longer each time, until the account answers (01huadalang on Discord: WorkBuddy 429s a free model while the account has credits, and magpie asks it again every minute) — a 429 the vendor gave no time for rested a minute, every time: an account refused again the moment it was back was asked once a minute forever, a request lost each time before the group's next model took it. The failover is magpie's (restAfter), so this is the same for the built-in and for the plugin, which passes WorkBuddy's 429 and its headers on as they are. Now rateRest counts the rate limits that come as soon as a rest ends (within half an hour of it) and rests 1, 2, 4, 8, 16 then 30 minutes; an answer starts it over (clearRest drops the note it counts by), one long after the last rest a minute again, and one while still resting — the last one left, tried anyway, or one request's own retries — keeps the count where it is. What the vendor says still counts: Retry-After or a reset header, or a reset time in the error as keepRetry notes it, when longer than the backoff. A rest is by the account (restKey) as before, by the model for OpenRouter's shared-pool free models. A usage that says the account has credits never put a resting account first (restLast orders after weighing); the test holds that. The Routing page says "rate limited again as soon as it was back (n times in a row)" for such a rest. TestRateLimitBacksOffWhenItComesBack fails on the old code (no count, a minute every time). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass but TestUserPath, TestSavedButSignedOutClaudeServed and one internal/gui test, which pass rerun. Not tried against WorkBuddy itself: its 429's body and headers weren't seen. 2026-10-03 22:34:36 +08:00