zcode 0.1.32: a plan's cap refusal is asked again, with no gate of the plugin's own (#395)
ZCode answers 429 with code 3008 "user concurrency limit exceeded" or
3009 "model concurrency limit exceeded" when one account has more in
flight than its plan serves. Such a refusal is now asked again, the same
bytes, after 250ms, 500, 900, 1600, 2800 and 4000 (jittered); one that
outlasts the waits goes on as a 429 with ZCode's words and what they
mean (busyAnswer). spentUp no longer counts 3008/3009 as a spent gift.
maxConcurrency: 3 is declared on the auth hook and as
magpie.maxConcurrency, as a default magpie's per-account queue applies
and a user can raise; the plugin keeps no gate of its own.
By ANDY-JK. Reviewed at 8dc0b8dade49001b3a0e89b5e26fd674e8657694, applied
onto main bf8faa2 (no zcode change on main since the branch's base):
- TMPDIR/HOME sandboxed, Bun 1.4.2: bun test in packages/zcode, 134 pass,
0 fail; bun scripts/check.mjs exit 0.
- PR CI (pull_request run 40323330525, merge ref): test and on-npm green.
- Broken by hand: busy() out of spentUp fails "the cap's own codes are
not a gift spent"; cap forced false fails the retry and outlasts-the-
waits tests; busyAnswer replaced by the plain body fails the latter;
concurrency.test.mjs against main's index.mjs fails at import.
- magpie origin/main e7173958e: host.js concurrencyOf reads both
declared sites. failure() reads the cap refusal as "rate" both before
and after busyAnswer, so a cap that outlasts the waits still rests the
account a minute as before; the README's "instead of resting the
account" is corrected in a follow-up.
- npm had 0.1.31; this is 0.1.32.
Not tried: a real ZCode account (the author measured one Z.ai gift-plan
account through magpie's gateway, numbers on the PR).
This commit is contained in:
@@ -128,9 +128,33 @@ coding plan; when the gift answers a trial entry with a quota error
|
||||
"exceed quota limit", which it can answer inside an HTTP 200) that too
|
||||
becomes a 429 and keeps the entry off for a minute. Any other gift
|
||||
answer (its 405, its 401, its 5xx) goes on as it came: the user picked
|
||||
the gift, so the coding plan is not spent behind their back. Every 429
|
||||
counts as spent, Z.ai's 1302/1303 rate limits among them. A stream's
|
||||
body is never read or buffered on the way.
|
||||
the gift, so the coding plan is not spent behind their back. Every other
|
||||
429 counts as spent — Z.ai's 1302/1303 rate limits among them — while the
|
||||
plan's own in-flight cap (3008/3009) does not: such a request is asked
|
||||
again instead (see [A few at once](#a-few-at-once)). A stream's body is
|
||||
never read or buffered on the way.
|
||||
|
||||
## A few at once
|
||||
|
||||
A plan serves one account a few requests at a time; past that, ZCode
|
||||
answers 429 with code 3008 "user concurrency limit exceeded", or 3009
|
||||
"model concurrency limit exceeded". magpie funnels every agent's and every
|
||||
session's requests of one computer through this one plugin process, so
|
||||
magpie's own queue spaces an account's requests by the number this plugin
|
||||
declares — `maxConcurrency` on the auth hook, and `magpie.maxConcurrency`
|
||||
in its `package.json`, both three. A request the vendor refuses anyway
|
||||
waits a moment (a quarter of a second, then longer — about ten seconds of
|
||||
waits in all) and asks again, the same request byte for byte. A cap that
|
||||
outlasts the waits goes on as it came, ZCode's words followed by what it
|
||||
is, so magpie can move that request along instead of resting the account.
|
||||
|
||||
Three is a default, not a cap the plugin enforces. A plan's real cap
|
||||
follows its tier — Z.ai serves a Max plan more at once than a Pro, and a
|
||||
Lite fewer — and is higher off-peak
|
||||
([Z.ai's usage policy](https://docs.z.ai/devpack/usage-policy)), so a
|
||||
number written into the plugin would hold a Max account to a Lite one's
|
||||
with no way to raise it. A user who knows their plan's cap sets it on the
|
||||
account or the provider in magpie, and magpie's queue follows that.
|
||||
|
||||
## The usage card
|
||||
|
||||
|
||||
Reference in New Issue
Block a user