Commit Graph
2 Commits
Author SHA1 Message Date
yetone 26864ec9b0 zcode 0.1.40: two accounts take requests at once, the others in reserve
01huadalang on Discord (#feedback): three ZCode accounts used at once
from one address got the address refused with a 405; two were served.
They asked for the first account to be used until it runs out, then the
next.

The plugin now declares maxAccounts 2, on the auth hook and as
magpie.maxAccounts in package.json, beside maxConcurrency. magpie (the
release after this, its provider setting Accounts at once) sends
requests to the first two accounts of the user's list only and holds the
others in reserve; one that runs out or fails rests and the first in
reserve takes its place. The user's own value on the provider wins, 0
for every account. A magpie that doesn't read the field uses every
account, as before. README: "Two accounts at once".

Run on mote: HOME=$(mktemp -d) bun test in packages/zcode (183 pass,
0 fail) and bun scripts/check.mjs (exit 0). Broken by hand:
package.json's maxAccounts set to 3 turns "two accounts at once are
declared, the same number twice" red. Not tried: real ZCode accounts
(none used, per the task), and whether two at once is always under
ZCode's limit; that is the reporter's finding, and the user can lower
it to 1.
2026-11-01 04:02:16 +08:00
ANDY-JK 8b21033daa 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).
2026-10-27 11:20:36 +08:00