Commit Graph
3 Commits
Author SHA1 Message Date
zhou.han 2f8e65a131 devin 0.1.38: a slow model list doesn't hold up quota usage (#977)
yetihan's change (fixes #976). usage() asks GetCliModelConfigs in the
background (freeIDs/configsFor with wait=false), so a slow or timed-out
model list no longer holds back the day and week windows that
GetUserStatus already returned. Free models (notModels) are added, or the
"Free models" row says why the list couldn't be read, on a later usage once
the ask has settled. Other callers keep wait=true. The asks are shared
through c.asking, failures back off for RETRY (60s), and the ask's own
try/catch means a background failure never rejects.

Reviewed at 3920118d53e7c144d9e7d54bfe6dca6069611575.

Run (WSL magpie-desktop, Bun 1.4.2, fresh HOME):
- bun test packages/devin: 209 pass, 0 fail; bun scripts/check.mjs: exit 0
- the same after merging origin/main into the head: 209 pass, check exit 0
- Windows (xiaomi-gpu, fresh HOME/USERPROFILE): bun test packages/devin,
  209 tests, 0 fail, 9 skip
- probe (not committed): 10 usages with a list that never answers make 1
  GetCliModelConfigs fetch; a fetch that throws makes 1 fetch in 10
  usages, the row names the error, and there is no unhandledRejection

Broken by hand: restoring the blocking freeIDs/configsFor calls makes
"a slow model list doesn't hold up quota usage" fail at 1017ms ("usage
waited for GetCliModelConfigs"), and the edited "logged once" test hangs to
its 5s timeout. Restored, both are green.

Version: npm had 0.1.37 and origin/main's package.json had 0.1.37, so the
bump to 0.1.38 is right.

Known: a usage read on a cold host (a fresh `magpie quota refresh` process)
returns the windows without notModels until the list has been read once.
"with no word from Devin..." now passes without its 503 being read.

Not tried: a real Devin account; Devin's API wasn't contacted.
2026-11-11 16:05:32 +08:00
yetone eee889afab devin 0.1.27: SWE-2 never goes as a paid -lightning variant or a bare family id, and an unreadable model list is said, not swallowed
zws13579 (magpie Discord #general, devin 0.1.26): a Devin Free plan
account ($0) can't use SWE-2 through the plugin, while Devin CLI/Desktop
can. They listed five places SWE-2 could be lost silently; checked each
against the code:

1. configsFor swallowed every error (real). Its reason is now kept
   (c.error), logged once to stderr when the asks start failing (the host
   routes it to magpie's log), and usage adds an aside row "Free models:
   unknown: Devin's model list couldn't be read (<reason>)" when a quota
   window exists and Devin has never answered for the account. The windows
   still count every model then (a failed read means unknown).
2. notModels only rides on a window (as designed: with no window nothing
   counts SWE-2). A plan with no quota window gives none and no error;
   a test holds that. The real gap behind it was 1, now visible.
3. A family the account's list leaves out (picked from SNAPSHOT's list,
   which the OpenCode config offers) went to Devin as the bare family id
   ("swe-2"). variantFor now falls back to SNAPSHOT's family, so it goes
   as swe-2-high (swe-2-max at max). The listing is unchanged: no model
   is added that the account's list doesn't have.
4. variantFor's effort-less default and listed()'s free check took
   f.models[0]. Devin's captures (10-14, 10-15) list swe-2-high first, so
   it isn't hit today, but a first -lightning variant (High cost tier)
   would have sent effort-less SWE-2 to a paid variant and unmarked it
   free. defaultModel skips such suffixed variants.
5. v2Models/v2Setup: not a magpie path. magpie's host loads server()
   (DevinAuthPlugin), whose usage hook carries notModels; OpenCode 2 has
   no usage hook, and a free model's cost there is already 0.

usage.test.mjs's stub answered GetCliModelConfigs with a JSON parse
error, so those tests ran with the model list unreadable; it now serves
a one-model list, so they test what they name.

Run (mote, from the repo root, as CI): HOME=$(mktemp -d) bun test:
3866 pass, 9 skip, 0 fail; bun scripts/check.mjs: every package ok.
Broken by hand: the new free.test.mjs against origin/main's index.mjs:
3 red (lightning default "swe-2-medium-lightning", bare "swe-2", no
"Free models" row), 6 green.

Not tried: a real Devin Free plan account. No Free plan GetUserStatus or
GetCliModelConfigs has been captured, so whether Devin gives a Free
account SWE-2 at the Free cost tier (its pricing lists free SWE-2 for
Pro) is unknown; nothing here assumes a shape for it.
2026-10-30 22:08:48 +08:00
yetone cff78b3424 devin 0.1.16: SWE-2 is free, so a used-up day and week don't hold it
太陽と向日葵 on magpie's Discord: SWE-2 costs nothing, but with the
account's quota used up magpie said so and didn't send SWE-2 to the
account, while a test of the model worked.

Devin's GetCliModelConfigs gives each model a model_cost_tier (field 24;
the CLI labels 1-4 "Low cost", "Med cost", "High cost", "Free"). On the
owner's account on 2026-10-14, of 262 configs only swe-2-high, -medium
and -max were 4. The plugin now reads that (parseFree), lists those
models and the entries standing only for them (swe-2) with free: true,
and gives the "1 day" and "7 days" windows notModels with their ids, so
magpie's allowance no longer counts them. ACUs are unchanged. When
Devin's configs can't be read, nothing is marked free and the windows
count every model, as before.

Run: bun test in packages/devin (58 pass) with HOME and TMPDIR in a
scratchpad dir; bun scripts/check.mjs. Broke it by hand: FREE_TIER=5
fails 3 of free.test.mjs's tests; dropping notModels fails the usage
one. Not tried: an account whose quota is really used up (the owner's
had 100% of the day and week left), so that Devin itself serves SWE-2
then is the reporter's word, not checked here.
2026-10-14 17:03:50 +08:00