Commit Graph
4 Commits
Author SHA1 Message Date
yetone cc3f000c6d qoder 0.2.48: a job token Qoder refuses as Login expired is renewed once and asked again (#474)
ahang39 (plugins#474): international Qoder answered dfmodel with 403
"Login expired" in bursts of ~16 requests over 2-5 minutes, about every
24h, shown by magpie as 401 "the sign-in lapsed". The report's times put
the burst's start where magpie's renewal came due (saved end less the
10-minute lead) and its end where the renewed pair was saved: Qoder
refused a job token the plugin still had as minutes from its end, and
nothing asked again with a renewed one. Why Qoder ended it early isn't
proven from the report.

- A chat's 401/403 now marks the failure lapsed. ask re-reads the saved
  sign-in under the refresh lock: a pair renewed meanwhile (another
  request, magpie's auth.refresh, another process) is used with no
  refresh; else the refresh token is spent once, the pair saved, and the
  request sent once more. A burst shares one refresh. A token this
  process renewed under 5 minutes ago that is refused too isn't renewed
  again, so a refusal not about the token's end doesn't churn refresh
  tokens; the 401 is said as before.
- A refreshed job token's end is read as an exchanged PAT's was:
  expire_time / expires_at (a date, or an epoch in s or ms) first, then
  expires_in, then a day. An end already past is ignored.

Run (mote, mote-run, HOME=$(mktemp -d), --timeout 60000; mote at load
20-28):
- packages/qoder: 320 pass, 0 fail.
- whole repo: 3129 pass, 1 fail: commandcode "a plan saved stands in
  for a subscription slow to read" (16.8s against its 3s bar), passes
  alone 13/13, filed as #475.
- bun scripts/check.mjs: ok.
- lapsed.test.mjs on the old index.mjs: 8 of 9 red. The 9th (magpie's
  own renewal begun during the refusal) was rewritten after that run and
  not run against the old code again.

Not tried: a real international Qoder account at the moment its token
is refused; the fake Qoder (refusal body {"message":"Login expired"},
single-use refresh tokens) is built from the report's words only.
2026-10-29 10:59:24 +08:00
yetone 26ddabe4de qoder 0.2.28: a queued request waits its turn in Qoder's queue and is sent again, as Qoder's client does (wallance on Discord)
wallance (Discord, magpie latest, qoder 0.2.27): Qoder's free deepseek
flash (dfmodel) through magpie ended in 503 "Qoder queued the request for
dfmodel (this plan's queue: p3); try again in 30s" after 27s, while Qoder's
own client answered the same model, slowly. magpie's gateway retries a
Retry-After of 8s at most, so the 30s was the agent's error.

What Qoder's client does, read from Qoder.app 0.4.3's
qoder-agent-sdk/dist/_worker/qoder-worker-runtime.obf.mjs ("[ModelQueue]"):
on a 10605 or a queue state it asks
GET <api>/algo/api/v2/service/ask/queue/status?requestSetId=&modelKey=&queueType=
(signed as any GET, X-Request-ID and X-Session-ID), at once and then every
retryAfterSeconds held to 0.5..30s (30s unsaid), while isQueued is true or
serviceAvailable false. Once isQueued is false it waits that state's
retryAfterSeconds and sends the same chatAsk again (same request_set_id),
up to 10 times; 3 failed status asks in a row, a 404 or a state with
neither field end it. It waits up to an hour (QODER_MODEL_QUEUE_MAX_WAIT_MS),
and tells /api/v2/service/ask/finish at the end of its turn, best effort
("server TTL will release the lease").

The plugin now does that, under a 4-minute budget from the request's
start: nothing reaches the agent meanwhile, and magpie keeps a stream's
agent alive with SSE comments for 5 minutes of silence (keepQuiet,
keepaliveLongest). Past it, the 503 with Retry-After as before, so magpie
may ask another account. A cancelled request stops the wait and sends
nothing more. The status path's /algo prefix follows the client's other
paths (it signs "/api/v2/model/list", the plugin calls
"/algo/api/v2/model/list").

Run: HOME=$(mktemp -d) bun test in packages/qoder, 185 pass; at the repo
root, 2114 pass, 0 fail, at 7fdc07f plus this change; bun
scripts/check.mjs ok. queue.test.mjs (10 tests) is 10 of 10 red on the old
index.mjs. busy.test.mjs now pins the budget to 0: its cases are Qoder
still queued once the wait is over.

Not tried: a real Qoder account (no credentials used), so the status
endpoint's reply and its /algo path are taken from the client's code, not
seen on the wire. Not done: the finish call (its body goes through the
client's wasm signer, which the plugin can't confirm), and request_set_id
is still per request where Qoder's client keeps one per turn, so each
request of an agent's turn may queue on its own.
2026-10-22 18:57:34 +08:00
lokic7123-star 656f3a1fb5 qoder: a trimmed or wrapped 10605 is busy, not a lapsed sign-in (#185)
`failure` parses the trimmed body, so a BOM-prefixed 10605 (the SSE envelope carries it as a JSON-escaped U+FEFF that `res.text()` doesn't strip) keeps its 503/Retry-After instead of reading as a lapsed sign-in. An outer body with no code, or code 401/403, whose message is a 10605 body is unwrapped to it; explicit 105/110/406 codes stay authoritative, and malformed or array messages are not unwrapped. Refs #167, #181.

What was run at c9e39e0 (reviewer, bun 1.4.2, macOS):
- bun test packages/qoder: 137 pass, 0 fail. bun scripts/check.mjs qoder: ok.
- Broken by hand: without the unwrap, the 8 wrapper tests go red; parsing `text` instead of the trimmed `msg`, the BOM test goes red; unwrapping regardless of the outer code, the explicit-code test goes red. The `inner.trim()` in events() had no test; a follow-up commit adds one.
- magpie (yetone/magpie main 85eef5d87) in a sandbox HOME, a copy of this package with api3/openapi pointed at a local fake, a planted plugin-auth.json, `magpie provider test qoder`: a 403 `{"code":403,"message":<10605 body>}`, the SSE `{"message":<10605 body>}` envelope and a BOM-prefixed 403 each gave 503 "Qoder is busy for efficient (this plan's queue: p3); try again in 30s"; a 105 still gave 401 lapsed. main's package gave 401 lapsed for the first two.
- Not tried: real Qoder accounts.
2026-10-17 17:54:35 +08:00
yetone f573cfdcba qoder: Qoder's queue (code 10605) is a 503 to retry after its wait, not a lapsed sign-in (#98); 0.2.14
failure() turned every 401/403 into "the sign-in lapsed — sign in again".
Qoder answered every chat on a real trial account (2026-10-12) with
403 {"code":"10605","message":"{...\"retryAfterSeconds\":30,
\"serviceAvailable\":false...}"}: its queue for the model, while the same
token read the models and usage.

Codes are now read as Qoder's own client reads them (the QoderErrorCode
table in Qoder.app's qoder-agent-sdk worker), whatever the HTTP status:
- 10605, or a queue state with isQueued or serviceAvailable false: 503
  with Retry-After from retryAfterSeconds (30 when absent), no
  X-Magpie-Sign-In. magpie's gateway counts a 503 as busy and asks again
  after Retry-After (patience.go busy/noteBusy).
- 110, 112-119, 122 (usage/credits used up): 429.
- 406, 416, 430, 80411, 80412, 100400-100403 (refusals of the request): 400.
- 105 (loginExpired) or no code: the 401 as before.
Both the HTTP status path and the in-stream statusCodeValue path go
through failure(); errorResponse sends Retry-After.

Run: bun test (sandbox HOME) 1137 pass 0 fail; bun scripts/check.mjs ok.
busy.test.mjs uses the literal body as testdata; its 4 tests all fail
against the previous index.mjs and pass with this one. Not tried: a real
10605 after the change (the account's queue was open again by then: a
real chat on fast answered "ok"); the quota and request codes' HTTP
status from Qoder is not seen, only their meaning from Qoder's client.
2026-10-12 21:22:50 +08:00