ac4af582301a4e8a29245dbba767eba31334ddf9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4cb7159f18 |
routing: a ChatGPT account whose usage can't be read is asked, not starved
peterpark8527 on Discord: 11 ChatGPT accounts under Use before expiry,
one never used. An account whose wham/usage reading fails (or names no
window, or is held by "When I ask") stayed not known for good:
Use before expiry counted it a fresh week (FreshPace, ~0.6/h), behind
every known week being spent; Smart put it after every known account.
NoteCodexLimits only updated accounts already read, so its replies'
x-codex-* headers never made it known. Its week, once started by
magpie's own turns or warm-up, lapsed unspent. A simulation of 11
accounts over 4 weeks (Pace, Poisson load 30/60/90%) had it at 141 of
~1200 used at 30% load, losing 3406, while every known account was used.
- provider: a reply that tells an unread account's week makes it known
from that (usedCache.heard), kept over failed readings, until a good
reading tells it; a 5h window alone still makes nothing up.
- gateway: a Codex account not known, weighed against one known, is
Learns, like Claude's: asked first once so its reply tells its week,
and again an hour after its last answer if that told nothing
(codexAnswered, codexLearnAgain). Of accounts none known the order
stands, so no week is started before it is needed.
- docs/reference.md: Smart and Use before expiry say so.
Ruled out (by design or not starving): an unstarted Codex week lasts
until its first request, so last is right for it; ties go by decayed
tokens, not a fixed order; a 5h-only account goes by its 5h pace
(ahead); rests are time-bound with probes.
Run:
- wsl-run go test -count=1 -timeout 45m ./internal/gateway
./internal/routes ./internal/provider ./internal/middleware: provider,
routes, middleware ok; gateway had 3 reds (TestAccountProxy,
TestCodexDrawMovesToNextAccount, TestWeeklyPace's five-hours case):
accounts none known reordered by answers earlier tests left in
codexAnswered. Fixed by the known-peer gate above; then wsl-run
go test -count=1 -timeout 45m ./internal/gateway ./internal/routes:
ok (809s). The none-known guard's u00 line was added after that run
and run alone on Windows (win-run -run TestUnknownCodexAccountIsAsked
./internal/gateway, with the reds above: ok).
- win-run the two new tests on the old code (
|
||
|
|
ef37b6fb76 |
gateway: an exhausted ChatGPT account no longer greys Codex app's Send while magpie can serve the turn (MasterYi on Discord)
MasterYi (#help, 1563467829687222343): with magpie wired into the Codex
app, a used-up ChatGPT account greys the Send button, so the third-party
models joined in Codex's picker can't be used either.
Cause, as far as the app's bundled code (ChatGPT.app 26.1013.40934,
read-only) shows: Send is gated in the app itself. It needs
authMethod == "chatgpt", the /wham/usage reading (fetched by the app
straight from chatgpt.com, not through magpie) saying not allowed, and
no credits. authMethod is read as the app opens or on account/updated,
which the app-server sends only on login/logout, not on a config change.
So the gate lifts only when model_provider is magpie AND the app has been
opened again. #540 already made magpie the provider while out, but only
when a magpie model was the default; on one of Codex's own models
(joined), nothing changed.
What changed:
- A (agent/codex.go Sync): joined on one of Codex's own models and the
account out (not Always ChatGPT, not magpie API), magpie becomes the
provider on that model as magpie serves it (codex/<model>), the model
kept in codex.out_own. Once the account has room, Codex is put back
joined on that model. A model picked meanwhile stays the user's. With
no ChatGPT account in magpie to serve it, nothing changes. New
Agent.AppOut says magpie is the provider for a used-up sign-in.
- C (provider/codex_app_out.go): a usage_limit_reached rest on the
active Codex account (gateway routing) or an x-codex-* window heard at
100% (NoteCodexLimits) has the account read again at once
(CodexMayBeUsedUp: active account only, at most every 20s, only
while a KeepOnAnAccountWithRoom loop has made its first reading and
still runs), not only on the 5-minute look. A first cut turned this
on for good as the loop started; every gateway test's Serve starts
it, so later gateway tests had accounts read again behind them, and
TestCodexOwnModelMovesToNextAccount and
TestCodexSpentMovesToNextGroupMember went red in the package run
(green alone 3 of 3). Now a counter, up after the first minute's
reading, down as the loop ends; the package run is green with it.
- B (gui/codex_app_out.go): the app open when the account ran out is kept
by its app-server's pid (provider.CodexAppOut; a new pid means it
reopened and read the provider, standing in for "authMethod is still
chatgpt"). On macOS, every 10s, magpie reopens it through the Agents
row's ReopenCodexApp when: AppOut, the account still out, the app is a
copy from before the config change, no turn in flight through the
gateway and none ended in the last 30s. At most once per time the
account runs out, success or not.
Drafts: the app's code keeps composer drafts in a persisted store
(composer-prompt-drafts-v2, 250ms debounce, flushed on quit), and
threads are server-side, so an unsent draft and open threads should
survive the quit. Not watched in a real app.
- D (GUI): Codex's accounts say "The Codex app can't send on {user}'s
used-up account": on macOS that magpie reopens it once no turn runs;
off macOS (no reopen path) or once tried, to quit and reopen it.
en, zh, zh-TW, ja, de.
Tests (each red on the code without its part, broken by hand):
- TestCodexOwnModelGoesThroughMagpieWhileUsedUp: red at "used up" with
the out case off, at "allowance back" with the restore off.
TestCodexOwnModelKeptOnChatGPT: Always ChatGPT stays.
- TestCodexMayBeUsedUpReadsAtOnce: red at "a window full: not read"
with the NoteCodexLimits hook off. TestCodexAppOutEpisode.
- TestCodexUsedUpReplyAsksAtOnce (gateway): red, asked [], with the
routing hook off.
- TestCodexAppOutReopenedOnce (gui, reopen stubbed): red at "a turn in
flight" with the idle check off, and at "again" with the once checks
off.
- codex-app-out.test.cjs: 40 of 40 (chromium, webkit; 900/480; five
languages; both texts); 2 of 2 red with the notice's call site off.
What was run, at this tree:
- gofmt -l: none. go vet ./... (darwin), GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./...: exit 0.
- go test -tags nogui -timeout 45m: internal/agent ok (414s, before a
comment-only reorder in Sync); internal/gateway ok (534s),
internal/gui ok (78s), internal/provider ok (137s), after the
live-check fix, at this tree before the previous commit's JS-only
move (then with a budget raise since taken back); internal/gui
again after the move.
- GUI (chromium, webkit), at this tree: codex-app-out, codex-app-stale,
i18n-keys, gui-de, gui-ja, gui-zh-tw and the files reaching the
previous commit's move: 164 of 164. Before the trim, every codex-*
and account-* file: 447 of 448; the red, codex-predictions chromium
ja 420 "picking a model scrolled the page", is #2624 and is red alone
on origin/main
|
||
|
|
0d55d9f6c2 | provider, gateway: a Codex account at its usage cap is held from the next turn on: each ChatGPT reply's codex.rate_limits event and x-codex-* headers update the account's reading, and routing's reading ages from when it was made, not when routing took it (up to two minutes old before); the cap's tooltip says a turn under way can still pass it (#1295) |