Files
magpie/docs
yetone 067e4c4846 gateway: Raccoon's token wall (user_model_rate_limited) isn't asked again in place (plugins#512)
SenseTime Raccoon answers an account whose token throughput is used up
with 429 {"error":{"code":"user_model_rate_limited","message":"您的模型请
求频率超限,请稍后重试","type":"rate_limit_error"}} and no Retry-After.
Its words read as a short rate limit, so the lone account was asked again
by the same-one retries (passing: 1, 2, 4s) and then by the plain
provider's patience (busy/replan: 2, 4, 8, 16s): eight asks in ~38s,
each one resending the whole ~88k-token request into the bucket it was
waiting on (cycocyco's numbers in plugins#512).

A 429 whose error.code is in wallCodes (only user_model_rate_limited) is
now neither passing nor busy. It still reads as failRate and rests as one
(a minute, doubled each time it comes back, up to 30 min, rateRest), so a
group's next member or the provider's next account is asked, and a lone
one hands the agent the vendor's error after one ask. The code is matched
at error.code only, not as words anywhere in the body. Other rate limits,
the same Chinese words under another code included, are retried as
before. The plugin passes the vendor's body through unchanged, so this is
the place for it.

Run (mote, at this change on origin/main 244d80e23):
- go test ./internal/gateway -run 'TestTokenWall|TestRateLimitIsWaitedOut|TestShortReset|TestLastOneLeft|TestGroup': ok
- gofmt -l internal cmd: clean; GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok
- go test -timeout 45m -count=1 ./...: every package ok except
  internal/gui, whose ten real-window AppKit tests (dock, panel, tray,
  titlebar, plugin page) were killed at their deadlines, mote's known
  state (#4125, #2645); this change touches no GUI code.
Rebased on origin/main 88e6fb9cf: go test -timeout 45m ./internal/gateway
./internal/usage: ok. Rebased again on 88e6fb9cf (routing.go's credit
rests changed, not the rate path): go test ./internal/gateway -run
'TestTokenWall|TestRateLimitIsWaitedOut|TestShortReset|TestLastOneLeft|
TestGroup|Rest|Credit': ok; the whole package not rerun there.
Broken by hand: with both !walled(body) guards taken out,
TestTokenWallIsNotRetriedInPlace is red (passes, busy) and
TestTokenWallFailsFast is red with "429 after 16 tries".
Not tried: the real Raccoon API (no account here), nor the reporter's
Hermes on Windows.
2026-10-30 15:40:49 +08:00
..