sherlock_23333 on X: once the ChatGPT account Codex is signed in to ran out, the Codex app's Send stayed greyed even on a magpie model, through restarts and reconnects. The gate is the Codex app's own (ChatGPT.app 26.1021, composer gM): Send is blocked while its authMethod is chatgpt and its own /wham/usage says rate_limit.allowed false with no credits. magpie's one lever is the takeover (codex.out): magpie becomes Codex's provider without requires_openai_auth, so the app-server reports no ChatGPT account and the gate lifts. That runs only when provider.CodexUsedUp says the account is held, and CodexUsedUp read LoginUsage, which returns nothing for a provider switched off or removed in magpie (leftAlone). So a user who turned Codex off in magpie once its allowance ran out never got the takeover, and one already taken over was put back on the held account. Now, with Codex left alone, CodexUsedUp reads the active account alone (codexHoldReading) while Codex takes magpie's models beside its sign-in or magpie is its provider for the held account (Agent.HoldMatters, via the new provider.CodexHoldMatters hook). At most once a minute (the loginReading cache), with the token as Codex keeps it, never renewed or written (codexTokenAsKept); the Usage page still shows nothing of it. Codex's prompts and base_instructions are untouched. Run atf41b63232+ this change, on mote via mote-run: gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...; go build ./... all ok. go test -count=1 -timeout 45m ./internal/provider ./internal/agent: ok (219s, 340s). Rebased on9f25de56c(a Cursor mover min and a GUI test), then at9f25de56c+ this change: go vet and go test -count=1 -timeout 45m of ./internal/provider ./internal/agent again: ok (178s, 273s).8c63c5b78(plugin speech models; no file in common) landed on main after that run and this is rebased onto it; the two packages were not run again with it. Broken by hand: without the leftAlone branch in CodexUsedUp, TestCodexHoldReadLeftAlone fails ("switched off: CodexUsedUp = false on a held account"); with the left-alone token read sent back through codexToken, it fails with the expired sign-in refreshed once. Not tried: the reporter's own config (whether their Codex was off in magpie is inferred, not confirmed); the real Codex app against a held account; internal/gateway's suite (no gateway code changed); Linux and Windows test runs (vet only).
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package agent
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// What the Codex app holds is read, Codex switched off in magpie or not,
|
|
// while it decides where Codex sends (sherlock_23333 on X): Codex on
|
|
// magpie's models beside its ChatGPT sign-in, or magpie its provider for
|
|
// the held account. Not for a Codex kept on ChatGPT, on magpie's API, or
|
|
// not on magpie at all.
|
|
func TestCodexHoldMatters(t *testing.T) {
|
|
home, _ := codexHome(t, `{"tokens":{"access_token":"x","id_token":"x.e30.x"}}`, "")
|
|
t.Cleanup(func() { codexUsedUp = func() bool { return false } })
|
|
cx := codex(home)
|
|
if cx.HoldMatters() {
|
|
t.Fatal("not on magpie: HoldMatters")
|
|
}
|
|
if err := cx.Fields[0].Set("fake/m1"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !cx.HoldMatters() {
|
|
t.Fatal("beside the sign-in: not HoldMatters")
|
|
}
|
|
codexUsedUp = func() bool { return true }
|
|
if err := cx.Sync(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !cx.AppOut() || !cx.HoldMatters() {
|
|
t.Fatalf("held, magpie its provider: AppOut %v, HoldMatters %v", cx.AppOut(), cx.HoldMatters())
|
|
}
|
|
// the hook the provider package asks
|
|
if provider.CodexHoldMatters == nil {
|
|
t.Fatal("provider.CodexHoldMatters not set")
|
|
}
|
|
for _, v := range []string{"chatgpt", "api"} {
|
|
if err := cx.Field("login").Set(v); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cx.HoldMatters() {
|
|
t.Fatalf("login %s: HoldMatters", v)
|
|
}
|
|
}
|
|
}
|