Commit Graph
32 Commits
Author SHA1 Message Date
yetone 418bb6c9e1 codex: Show Codex's own models off leaves them out of Codex's own picker (iiiiiimone on X)
The switch (#1642) only narrowed the Agents page's pickers. Codex's own list,
which the gateway hands it beside its sign-in and as the Codex app's list
file, kept every model of the ChatGPT account, also with the Codex provider
switched off. codexMerged now leaves the sign-in's visible models out when the
switch is off (provider.CodexOwnLeftOut); the model Codex is set to, models
magpie serves on a ChatGPT account and hidden jobs stay, and the list's ETag
carries the switch so Codex asks again. Codex has one openai_base_url for every
model, so one it is still set to goes through the gateway to OpenAI on its own
sign-in; a model of it can't be sent direct beside magpie's models.

Run: TestCodexListWithOwnModelsOff, red with the filter turned off (own models
all listed, ETag unchanged); gateway, provider tests at this tree.
Not tried: a real Codex app against the list.
2026-11-11 01:54:05 +08:00
yetone d1cdce1302 provider: the group alone keeps subscription models out of agents' lists (shaoyang.)
shaoyang. on Discord (#general, 11-03): with a routing group's Model
lists set to the group alone (its card's 成员模型不单独列出), the model
list fetched still had every model of the group.

Cause: 88e6fb9cf (v0.1.2176, 10-30) had catalogOf keep a signed-in
subscription's models (SubscriptionKept: a ChatGPT, Claude, Copilot or
plugin account's) for every agent, leaving the group alone only for a
client that is no agent (""). Over HTTP no client is "": agentOf falls
back to usage.AgentOf(User-Agent), which is "other" or the UA's name, so
every /v1/models fetch, every agent's written list and every picker
listed a subscription member beside the group. For a group made of
subscription models, as most are, the option changed nothing.

Fix: catalogOf gives every agent but Codex Catalog(), as before
88e6fb9cf; Codex keeps its ChatGPT sign-in's own models (CodexOwn,
a3ee00c05), which its app reaches on that sign-in. SubscriptionKept is
gone; Unlisted() and GroupKept() name subscription members again, so the
picker's "kept for routing groups" note and the provider editor's
"listed alone" line (3d063e34f) say where they went. The routing editor's
hint says Codex keeps its own, in en, zh, zh-TW, ja and de. Docs:
reference.md, gateway-routing.md.

Behaviour change for 士奇's case (88e6fb9cf): with "The group alone" on,
Hermes, WorkBuddy and the rest lose the group's subscription models
again; that is what the option says. Listing its models too keeps them beside
the group, which the new test checks.

Tests:
- gui TestGroupAloneKeepsSubscriptionModelsOutOfEveryAgentsList (replaces
  TestSubscriptionModelsStayInEveryAgentsListWithGroupOn): a sandbox
  ChatGPT sign-in's 5 models in a group listing alone. For every agent
  but Codex that lists the group, its Agents-page list, CatalogFor and
  model pickers leave them out; Unlisted names them; with "Its models
  too" hermes, workbuddy, claude and codex list them.
- gateway TestGroupAloneKeepsSubscriptionModelsOffAgentsModelList:
  GET /v1/models with no key, "magpie" and magpie-hermes/-claude/-opencode
  lists group/mine and not its members; /v1/models/{id} doesn't find one
  for Hermes; Codex's key lists and finds them; listed again with
  listed too.
- TestCodexOwnModelsListedOnlyThroughGroups again expects Claude Code not
  to list a group-alone member.

Run on mote at 3da80330a (rebased on origin/main c3593dc49): gofmt -l
clean; go vet (darwin -tags nogui, GOOS=linux -tags nogui at the base,
GOOS=windows) on provider, gateway, gui ok; go test -timeout 45m
internal/provider ok, internal/gui ok, internal/gateway -run
"TestGroup|TestCodex|TestUnlisted|TestModels|TestDesktop" ok. At the
base 40a287b21: internal/provider, gateway, gui and agent whole ok;
internal/cli red only in TestEveryRouteHasACommandOrIsNamed (GET
/api/context/reply, #5026, red on main since 0872bc2a0). GUI:
group-unlists (en/zh/zh-TW/ja/de, 1100 and 420px), unlisted-group-kept,
unlisted-models, agent-models-group-on, i18n-keys in chromium and webkit,
56 of 56.

Broken by hand: catalogOf back to SubscriptionKept with the new tests in
place; the gui test failed with 484 "the group alone" errors (codex/gpt-5.5
in claude's, claude-desktop's, claude-science's lists and pickers among
them) and the gateway test for every key, no key and "magpie" included.

Not tried: a real ChatGPT/Claude sign-in or the running app, and the
reporter's Docker deployment (same /v1/models path, no OS branch); which
agent fetched the list isn't known.
2026-11-03 18:23:13 +08:00
yetone ffa07395eb gateway: Codex talks Responses to magpie over a WebSocket, turns after the first as a delta (#4058)
Codex names previous_response_id and sends only the new input on its
WebSocket path alone; magpie answered the upgrade 426 (a87dc1ff2), so
Codex fell back to HTTP and re-sent the whole conversation, images
included, every turn (kevinzhow and neighbads on X).

/v1/responses, /responses and /backend-api/codex/responses now accept the
socket (responses_ws.go), with Codex's protocol (codex-rs 2f1e4f9,
responses_websocket.rs):
- each response.create frame is replayed as the POST it stands for through
  the outermost handler the upgrade came in on (socketEntry wraps Front and
  Handler), so the allow list, rebound Host check, key, corsGuard,
  keyLimited, routing, failover, usage and log judge every turn;
- previous_response_id resolves to the socket's own last two replies
  (input + output items); the provider gets the whole conversation, so a
  switch of account or provider mid-chain loses nothing. An id the socket
  doesn't hold is previous_response_not_found (Codex reconnects with
  everything);
- generate:false (warmup) is answered locally; response.interrupt cancels
  the turn (accepted + incomplete/interrupted, or failed); errors are
  Codex's error frame with status and the headers it acts on;
  response.metadata, codex.response.metadata (x-models-etag, magpie's tag)
  and codex.rate_limits are sent as the backend does;
- shutdown drains sockets with 1001 and refuses new ones 503.
Codex needs no config change: magpie's wiring points the built-in openai
provider at /backend-api/codex, which Codex already speaks WS to. Other
Codex backend paths still answer 426. Docs: gateway-routing (new section
"A Responses WebSocket"), providers-accounts, reference.

Run at the pushed head (rebased on origin/main 430005726), on mote:
gofmt -l clean; go vet ./internal/gateway for darwin, linux, windows;
go test -timeout 45m ./internal/gateway: ok (480s).

Real Codex (codex-cli 0.165.0, sandbox HOME/CODEX_HOME with a copy of the
owner's ChatGPT auth, sandbox magpie on 127.0.0.1:3481, gpt-5.6-luna, a
task with three tool calls). At the pushed head, built on mote: exit 0,
right answer, 5 turns on one socket, 4 continued, 75480 B received vs
278210 B sent on as whole requests, no fallback to HTTP. Before the
rebase, with a temporary per-turn log: exit 0, right answer. 5 turns on one socket,
4 continued with previous_response_id; frames 58073 B (first), then 4465,
3051, 3093 B, against 58.7-66.6 KB had each been a whole request. 70185 B
received over the socket vs 255379 B sent on as whole requests.

Broken by hand:
- serveResponsesSocket returning false (the old 426): 9 of the new tests
  red.
- turns sent straight to the Responses handler with the upgrade's
  post-guard context: TestResponsesSocketGuards red (a key turned off
  still served; a 700-token limit not held).

Not tried: images in a real run; Codex on Windows/Linux. Not done: the
leg magpie -> vendor still sends the whole conversation each turn (for
ChatGPT, keeping an upstream socket per client socket would save that);
the saving is Codex's upload to magpie. A socket's conversation does not
survive the socket or a restart (Codex then resends everything).
2026-10-30 08:51:03 +08:00
yetone 442897f414 gateway: masking time is kept when magpie's own time is unknown
A masked request's "Masking" part on the Routing page comes from
Route.Masking, which maskingMs capped at Own, magpie's own time before
the request went out. Own is known only when magpie's client wrote the
request and a first token came back, so a request that was masked but
went through a plugin, through Claude Code for a Claude subscription,
failed, or had no first token had its masking time dropped to 0, and
the page showed nothing for it (Discord, lute: some requests show the
masking and model time and some don't). The Codex backend path never
set it at all.

maskingMs now keeps all of the masking time when Own is unknown, and
still caps it at Own when Own is known. The Codex backend path sets it
on its route and its usage record. The usage page still shows Masking
only beside a known Own, as before.

Run (mote, go1.26.8):
- TestMaskingTimeKeptWhenOwnIsUnknown (a masked request the vendor
  refuses): red on the old redact_phase.go ("masking 0 ms, held
  120ms"), green with it.
- TestCodexOwnSignInKeepsItsMaskingTime: red without the codex
  backend lines ("route's masking 0 ms, held 120ms"), green with them.
- TestMaskingIsAPhaseWithItsTime, TestNoMaskingNoMaskingTime: ok.
- go test ./internal/gateway ./internal/usage -count=1 -timeout 45m with
  this and the next commit: ok (gateway 502s, usage 16s).
- go vet ./internal/gateway ./internal/usage for darwin, linux
  (-tags nogui), windows: ok. gofmt -l: clean.
2026-10-30 01:54:40 +08:00
yetone 5dc908f764 gateway: a turn on Codex's own sign-in says where its time went
The Routing page's "Where the time went" (magpie, network, vendor) is
drawn from a try's TryNet, which only the routed path (gateway.go)
recorded. A turn Codex sends on its own sign-in or its API key goes
through the Codex backend path (codex_backend.go), out through the same
Go client, and its try never had one, so those requests showed no time
split while routed ones did (Discord, lute: some requests show magpie's
and the model's time and some don't).

Each Codex backend try now traces its requests (netTrace) and records
its TryNet when it ends or is handed on for an overload; a request asked
again within the try (a reset spent, a dropped large one, an item taken
out) counts as its Before. A turn asked again for an overload gets a
fresh trace, and its TTFT/FirstText are now from its own Start, as
Try.TTFT is documented, so its "First token" part isn't inflated by the
tries before it.

Run (mote, go1.26.8):
- TestCodexOwnSignInTellsWhereItsTimeWent: red on the old
  codex_backend.go ("no timing for a turn on Codex's own sign-in"),
  green with the change.
- go test ./internal/gateway -run 'TestCodex|TestTryTellsWhereItsTimeWent|TestTryNet|Overload': ok.
- go test ./internal/gateway -count=1 -timeout 45m at this change
  (base 8cbd0a9c9): ok (527s).
- go vet ./internal/gateway for darwin, linux (-tags nogui), windows: ok.
- gofmt -l: clean.
Not tried: a real Codex sign-in through the GUI.
2026-10-30 01:54:40 +08:00
yetone a3ee00c05c codex: its own GPT models stay in Codex's list when kept for routing groups
士奇 (Discord, 10-28): with a routing group on, the Agents page's Codex
list lost its Codex provider section and models, the model dropdown still
offered GPT, but the Codex app had none; with the group off they came back.

Cause: the codex provider's "Only through routing groups" (Provider.Unlisted,
只通过路由分组使用), or a group that lists itself alone (Group.Unlists), took
the ChatGPT account's own models out of Catalog(), so out of Codex's own
list too. With no Codex section, the own options were not magpie's, so the
own-models switch showed and the picker kept offering GPT; meanwhile #1602
(125dad5cb, CodexNativeUnlisted) dropped every one of them from the list
handed to Codex (backend /models, the model_catalog_json desk file,
spawn_agent). The picker and the app disagreed.

Why the earlier fixes missed it: aa766289b only stopped the GUI folding a
provider, and 508911e43 (TestCodexOwnModelsStayWithGroupOn) only kept
Served own options in the picker. Both covered a plain group; neither
touched Catalog's unlisting for Codex or the desk list's #1602 filter, and
neither test set Unlisted or Unlists.

Fix: Codex's lists start from catalogOf("codex"), which keeps CodexOwn
entries (ListedFor/CatalogFor, CodexNativeHidden, CodexOrder), and
CodexNativeUnlisted is removed with its filters in codexMerged,
spawnChoices and the list tag. Other agents and /v1/models still don't
see unlisted GPT models (checked for Claude Code in both tests).

Behaviour change for #1602: an unlisted codex provider no longer hides GPT
from Codex. The way to hide them from Codex is Codex's own list (its Codex
section's hide / only-picked), which CodexNativeHidden still applies; the
rewritten gateway test checks that and the ETag change.

Tests:
- gateway TestCodexModelListKeepsOwnForGroups (rewrites
  TestCodexModelListUnlistedForGroups): group Unlists and provider Unlisted
  keep gpt-6-sol/gpt-5.5 in Codex's /models and spawn_agent; Claude Code
  doesn't list them; hidden in Codex's list it goes and the ETag changes.
- gui TestCodexOwnModelsListedOnlyThroughGroups: agentModelList has the
  Codex section (Own) for every model, OwnModels is false, the picker has
  them, Claude Code doesn't list the unlisted ones.

Run (mote-run, -tags nogui): go build ./...; go vet for darwin, GOOS=linux
and GOOS=windows on provider/gateway/gui/agent; gofmt -l clean; go test
./internal/provider ./internal/gateway ./internal/gui ./internal/agent: ok.
Broken by hand: the five source files reverted to f20118304 with the new
tests in place: both tests red (gateway: gpt-5.5 and every own slug gone,
spawn offers only group/mine; gui: no Codex section, own switch shown).
Real codex 0.162.1 in a sandbox CODEX_HOME: `codex debug models` with
model_catalog_json pointed at the desk file CodexDesktopCatalog wrote with
the provider Unlisted and an Unlists group lists gpt-6-sol, gpt-5.6-sol and
group/mine (the old code dropped both GPT slugs).

Not run: full suite. Not tried: GUI Playwright files (no page changed), a
live ChatGPT sign-in or the Codex desktop app itself.
2026-10-28 14:26:18 +08:00
yetoneandggbdpq 7f0f71a0ef gateway: a refused or empty-failed Codex relay's call carries its route (#2481)
The Routing page's "Request and response" finds a request's call by its
route (RouteCall). Of codexUpstreamOn's three record exits only the
success one set Call.Route, so a turn whose API key OpenAI refused (401)
or that the backend failed with nothing said opened as "the request is
gone" though its call was one of the last 40. Both failure exits now
carry the route through routeOf, which is 0 for a compaction: both exits
are reached by /responses/compact too, where no route opens.

Reported with a patch by ggbdpq (gua2100 on Discord). The patch set
Route: tr.ID unguarded on the empty-failure exit; since the
outrageous_piglet change that exit also takes a compaction, where tr is
nil, so that line panics on a compaction failed with an empty body.
routeOf guards both exits. gui-shell.md says which Codex exits carry
the route.

Run (sandbox HOME, caches pinned):
- TestCodexKeyRefusedCarriesItsRoute, TestCodexEmptyFailureCarriesItsRoute
  (ggbdpq's, the asserts moved into routeHasItsCall) and the new
  TestCodexCompactEmptyFailureRecordsNoRoute: ok.
- Broken by hand: with both exits back to no Route, the first two fail
  "route N: no call in the ring, so Request and response says the
  request is gone"; with the patch's unguarded tr.ID on the empty exit,
  the compaction test panics (nil pointer dereference). Restored: ok.
- go test -tags nogui -run 'TestCodex|TestRouting|TestArchive|TestRouteCall'
  ./internal/gateway: ok (31s).
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
  ./internal/gateway: clean.

Not tried: a real OpenAI 401 or a real empty ChatGPT backend failure
(fake upstreams); the GUI's routing-bodies test (the GUI is unchanged);
the full ./... suite (one suite per machine, others running).

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-28 00:41:37 +08:00
yetone 479de89001 gateway: Codex's model list is asked of the backend once for every app-server, and kept, so it comes within Codex's 5 s (#3734)
#3734: with ~20 Codex app-servers starting together, Codex logged
"failed to refresh available models: request timed out" 1,906 times a
day, fell back to its default metadata for magpie's groups (no
supports_search_tool), and inlined ~1,075 Apps tools: ~500K input tokens
a turn.

Each /backend-api/codex/models asked the ChatGPT backend on its own, and
gave its ask up at codexModelsWait (3 s). Measured with a minimal
gateway (gateway.New().Handler() alone, sandbox HOME, no providers), 20
lists at once with a real ChatGPT sign-in's headers, as app-servers ask:
- 4a33cf0a9: mean 2.24 s, max 3.01 s; the one at 3.01 s was handed an
  empty list (16 bytes), the backend asked 20 times. Again right after:
  mean 1.04 s, max 1.72 s, 20 asks again.
- this change: mean 1.72 s, max 1.74 s, all 20 the full list (568,401
  bytes) from one ask; again right after: max 0.01 s.

Now the backend's list is kept for each sign-in (account id, the
backend, Codex's version): within codexListFor (a minute) it is handed
out again; past it, handed out at once while one ask goes; with none,
the callers wait on the one ask for up to codexModelsWait as before,
and the ask goes on, up to 30 s, for the callers after, where a backend
slower than the wait had never got a list through. A 401 or 403 is
still Codex's to see, and no list from before is handed out in its
place. Each caller reads its own copy, since the windows, picks, V1
stamp and auto-review are written into the entries.

What changes for users: the account's own models (not magpie's, whose
part is built per call) are up to a minute behind the backend.

Not changed: Codex's own 300 s cache and the build of magpie's part
under provider.Hold (#746); no model_catalog_json floor is written.

Tests (codex_models_shared_test.go):
- 20 lists at once, the backend held: each answered with magpie's
  models and Codex's last list, the backend asked once; let go, its
  list reaches the next caller; fresh, five more ask it no more. On
  4a33cf0a9: asked 20 times, then 5 times more.
- a backend always 600 ms against a 200 ms wait gets its list through:
  red on 4a33cf0a9 (none in 10 s), green here.
- stale: three answers at once while the backend holds its second ask.
- a refused sign-in after a list: the 401 is passed on.
TestCodexModelListOnlyPicked and TestCodexNativeModelsTakeSetWindows
change the backend's list between calls, so they forget the kept one
there (forgetCodexLists, which also waits for every ask a test began).

Run at this head (cm3734 worktree, base 834935149):
- go test -race -count=10 on the five list tests (the four new, BackendSlow): ok.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway/: ok;
  gofmt -l clean.
- go test -timeout 45m ./internal/gateway/: ok (429s), run before
  TestCodexModelListBackendAlwaysSlow was added; that test then run
  alone and in the -race run above: ok.
- Rebased onto 80857a66c (13cca8109 touched codexcat and Codex's
  models since): go test -run 'Codex|Fast' ./internal/gateway/: ok (42s).
2026-10-26 23:41:35 +08:00
yetone 42976f9a08 usage: a renamed provider is shown once, by the id it has now
cybercaius on Discord (#help, 10-25): "已经更改供应商 id 的也没有变更过来反而
分开显示了". Reproduced in a sandbox HOME (magpie web on 3582, fake upstream
on 3583): after renaming myrelay to newrelay in the editor, the Requests
page's provider list had both myrelay and newrelay, each named "myrelay",
because the model-list probe row was still under myrelay. The summary was
already folded; the probe chunk, the Sessions tab's vias and the gateway's
loggedAnswers (lead-first routing) were not renamed at all.

What changed
- provider.Renames (UsageRenames): Of(id, time) is the id a call recorded
  under id at that time belongs to now. Every usage reader goes through it:
  summarizeFrom (and its historical-key set), ledgerMatched, NewPricer,
  NewCoster, the Requests page's gateway blocks, probe rows and other
  computers' days, window holds and their history, buildVias, and
  gateway loggedAnswers. Visit stays as recorded so Of is taken once.
  The summary, Requests and vias caches key on Renames.Key.
- An id reused by another provider no longer pulls the new one's calls
  into the old one. Rename onto, or Save of a new provider under, an id in
  another's Was moves it into that one's Gave with the time (giveID):
  calls before then stay the old provider's. freeID treats Was ids as
  taken, so adding the vendor again gets "-2". Renamed() (refs) skips ids
  a provider or subscription holds now.
- A providers.json that can't be read keeps the last renames read instead
  of none (a failed read is unknown), so usage doesn't split meanwhile.
- History: nothing in usage.jsonl is rewritten. Calls from before this
  release under a renamed id show under the new id at once. An id that was
  reused before this release has no hand-over time, so its calls show under
  whoever holds the id now, as before.

Siblings checked: budget keys by caller key; per-key limits, RPM and
concurrency count live requests by the current id; tray totals go through
QueryPage; codex_memory reads Requested refs. None needed a change.

Run at the tree before the rebase; rebased onto 894603bcd (GUI-only,
none of these files) and provider, usage, usageapi, the build and the
Rename/Answer/Lead tests of gateway and gui run again there: ok.
- TestRenamesByWhenTheIDWasTaken (provider), TestRenamedProviderShownOnce
  (usage), TestRenamedProviderAnsweredItsLead (gateway): each red with its
  piece broken by hand (Save's giveID, freeID's Was, the last-good renames,
  probe rename, vias rename, block pricer's timed path, summarize's time,
  loggedAnswers' rename), green with it.
- go test -timeout 45m provider usage usageapi budget middleware cli agent
  gui gateway sessions profile tui: all ok.
- gofmt -l, go vet ./internal/..., GOOS=linux/windows -tags nogui vet of
  provider/usage/gateway and build of the binary: clean.
- Sandbox: rebuilt binary on the same HOME; /api/usage/requests lists only
  newrelay, the probe row included.

Not tried: the GUI suite (no JS or asset changed; /api/providers gains an
omitempty "gave"), Windows tests run on the Windows box, a real account,
and the full ./... suite (other sessions' suites were running).
2026-10-25 10:53:45 +08:00
yetoneandggbdpq 540454acec gateway: a turn on Codex's own ChatGPT sign-in is counted on that account, so the card's window holds see it (#2297, Edward4226, ggbdpq)
codexUpstreamOn wrote the relay's ledger row as Provider: call.Provider
("openai") with no account. The account card's window holds key rows by
codex + the sign-in's email (usage/window_holds.go), so every turn Codex
relayed on its own sign-in was left out: the reporter's 7-day window read
2.3M/$0.31 where its calls were 19.0M/$64.26.

codexServed (ggbdpq's patch) records such a relay as the codex account
signed in to, or the account compactOn signed it with. An API-key call
and a relay with no sign-in to name stay openai with no account. The
Routing view's seat stays OpenAI. loggedAnswers (#1367) still leaves the
relay out of a lead's answerers, as openai or as codex without a
"host as email". Rows already written are not rewritten.

On top of the patch: the relay goes out with the token Codex sent, which
is the sign-in magpie reads only when it is the same ChatGPT account. A
request whose chatgpt-account-id isn't the account auth.json here is
signed in to (a Codex in WSL, another CODEX_HOME) stays openai rather than
being put on this machine's account (provider.CodexSignedInAccount).
TestCodexServedNamesTheAccountThatSigned is back and covers it.

Run, go1.26.8 darwin/arm64, on 03eb0633a, -tags nogui -p 1:
- go test ./internal/gateway -run 'TestCodex|TestSealedTaskFromChatGPTLead|
  TestLoggedAnswer|Lead': ok (48.8s). The four new tests -race -count=3: ok.
- go test ./internal/provider -run 'TestSessionIdentit|TestCodex': ok;
  ./internal/usage -run 'Window|Hold': ok.
- go vet ./internal/gateway ./internal/provider for darwin, GOOS=linux and
  GOOS=windows: clean. gofmt -l: nothing.
Broken by hand, each red, then put back:
- codexServed always "openai": TestCodexOwnModelRecordedAsCodexAccount
  (Provider:openai, no account) and TestCodexServedNamesTheAccountThatSigned.
- chatgpt-account-id check dropped: TestCodexServedNamesTheAccountThatSigned
  ("another account's token: codex me@example.com").
- loggedAnswers back to provider == "openai" only:
  TestCodexOwnModelRecordedAsCodexAccount and TestCodexOwnRelayAnswersNoLead
  ("own sign-in answered a lead").
ggbdpq's own record (Windows, 38d25fe3/1d61458b on 01c41e8b): the same
tests red with codex_backend.go reverted, green after; -race -count=5;
vet/build for windows, linux, darwin.
Not run: the full suite, GUI, a real Codex sign-in.

Full suite: SUITE_LINE

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-15 23:08:01 +08:00
yetone 125dad5cbb gateway: a codex provider used only through routing groups keeps the ChatGPT account's own models out of Codex's list (#1602)
With Codex signed in to ChatGPT, Codex asks magpie's /backend-api/codex/models
for its list, and codexModels passes the backend's own models through,
narrowed only by the codex provider's picks (CodexNativePicked) and the
Agents page's hides (CodexNativeHidden, built from Catalog()). A provider
set to "Only through routing groups" (Provider.Unlisted) has none of its
models in Catalog(), so neither filter saw them: all of the account's
models stayed in Codex's picker, and the Agents page had no Codex group to
hide. Every other agent's list is Catalog-based and already left them out.

provider.CodexNativeUnlisted says which of the account's models are kept
out of agents' lists: every one when the codex provider is Unlisted, and by
slug those a group with Unlists names. codexModels drops them (hidden
entries such as codex-auto-review stay, as with picks; a Codex reached for
failover alone keeps them, as it is handed no groups), spawnChoices drops
the same ones from spawn_agent's list, and CodexListTag carries them so
Codex refetches. gateway-routing.md says so.

Test: TestCodexModelListUnlistedForGroups (a group unlisting gpt-5.5 takes
gpt-5.5 alone; the provider Unlisted takes gpt-6-sol and gpt-5.5 and keeps
codex-auto-review; ETag changes; spawn_agent offers neither; own-only keeps
them). With codex_backend.go and codex_spawn_models.go reverted it fails on
all three checks. Not tried with a real ChatGPT sign-in and Codex app.

Run (sandbox HOME, private GOCACHE, worktree at origin/main 97dfed0f3):
gofmt -l; go vet ./... (darwin), GOOS=linux -tags nogui, GOOS=windows;
go build for all three; go test -tags nogui ./internal/gateway
./internal/provider ./internal/catalog ./internal/codexcat: all ok.
2026-10-13 05:05:23 +08:00
yetone 61e296688e gateway: Codex's model list keeps codex-auto-review when the user picked models on the ChatGPT account, so auto-review runs on it again, not on the conversation's model at low (#1460)
10086gg reported that Codex's auto-review through magpie almost never
used codex-auto-review. It ran on the conversation's own model at low
effort, which costs more.

Cause: codexModels narrows the ChatGPT backend's list to the models the
user picked on the codex provider (CodexNativePicked). Hidden entries
(visibility "hide") never reach magpie's catalog (parseCodexModels), so
no one can pick them, and the narrowing always dropped them.
codex-auto-review is one of those hidden entries. Codex 0.162 picks the
reviewer this way (codex-rs/ext/guardian-reviewer/src/model.rs,
select_review_model):
1. the entry's auto_review_model_override;
2. else codex-auto-review, if the list has it;
3. else the conversation's model, at low effort.
So once the list was narrowed, every review fell to step 3. On a relay
model it was charged to the relay; on a ChatGPT model it ran on that
model. OpenCodex had the same bug: lidge-jun/opencodex#6712 recorded
direct ChatGPT login as codex-auto-review/low and their proxy as Sol/low.

Fix: the narrowing keeps hidden entries. No picker shows them, so the
user's picks still decide what Codex's /model lists. A user who wants
reviews on a relay model can still set Codex's auto-review model
(#938), and that setting still wins (step 1).

Which account pays changes for a user with picks whose conversation
runs on a relay model: auto-review moves from the relay to the ChatGPT
account's codex-auto-review. That is what Codex does without magpie.
OpenAI's help article "Using Codex with your ChatGPT plan" says:
"When you're signed in with a ChatGPT account, auto-review safety
checks are free and don't count toward your plan's usage limits."

New test TestCodexModelListPicksKeepHidden. It fails on the old code:
after the picks only gpt-6-sol is listed, with no codex-auto-review.
docs/subsystems/gateway-routing.md says this.

Run:
- gofmt -l internal/gateway
- go vet -tags nogui ./internal/gateway, on darwin, linux and windows
- go test -tags nogui ./... with a temp HOME and pinned caches: green
Not run: a real Codex signed in to ChatGPT through the gateway. The
reviewer choice was read from the Codex source.
2026-10-10 13:30:43 +08:00
yetone 0b5b10da2a agent, gateway, gui, tui: a Codex that goes through magpie only to fail over to the user's other ChatGPT accounts says so on the Agents row and keeps to its own models (#1385, shenghsi)
With several ChatGPT accounts on, failover writes openai_base_url into
~/.codex/config.toml so a turn the signed-in account can't pay for goes on
to the next account. With Codex's switch off, the row said only "not
connected", but every request still went through the gateway, and the
gateway's /backend-api/codex/models answer added all of magpie's models
(62 for the reporter).

- agent: Agent.FailingOver means not wired, while the stash's codex.failover
  (or a CC Switch mirror's codex.mirror_failover) base URL points at magpie.
  FailoverSaid is the line the CLI list and the TUI show. CodexOwnOnly is
  true for this machine's Codex when it is failing over and no WSL Codex is
  connected, since a WSL Codex shares the gateway path. Sync ages a
  models_cache.json that isn't tagged with the own-only list.
- gateway: codexModels leaves out provider.CodexListed when
  gateway.CodexOwnOnly (set by main to agent.CodexOwnOnly) says so. The
  ETag and X-Models-Etag carry provider.CodexOwnListTag. Neither tag
  contains the other, so Codex fetches the list again when it is connected
  or disconnected.
- gui: /api/state carries failover. The row says "Not connected · goes
  through magpie only to fail over to your other ChatGPT accounts". Its
  title says what turns it off. A "ChatGPT accounts" button opens
  Providers › Codex. Strings are in zh, zh-TW, ja and de. openProvider no
  longer draws the Providers list before it has loaded. It was only safe
  once the tab had been opened, and this is its first caller from another
  page.
- docs: agent-wiring and gateway-routing describe the failover-only Codex
  and list the new tests.

A user's hand-written openai_base_url (#856) isn't failover's, so it stays a
plain not-connected row.

Verified:
- TestCodexFailoverOnlyKeepsOwnModels (agent) builds the reporter's state in
  a temp HOME: Codex signed in, two more ChatGPT logins on, Sync, so the
  stash has codex.failover=1 and no joined/beside. It checks that the row is
  not wired and is FailingOver, that FailoverSaid names Providers › Codex,
  and that the real gateway handler's /backend-api/codex/models lists only
  the backend's gpt-5.5. It also checks that the cached full list is aged,
  and that after Join magpie's fake/m1 is back.
- TestCodexModelListOwnOnlyForFailover (gateway) checks the list and both
  ETags with the hook on and off.
- agent-failover.test.cjs checks the row text, title and button in en, zh,
  zh-TW, ja and de, at 980px and 420px, in Chromium and WebKit (20 pass).
  It also checks that the button opens Codex's editor, that the page
  doesn't scroll sideways, and that no click moves it.
- Broken by hand, each test goes red:
  - codexModels ignoring the hook fails both Go tests.
  - failingOver returning false fails the agent test.
  - dropping the Sync cache case fails the agent test.
  - removing the GUI branch fails the GUI test.
  - drawing the list before it has loaded (the old openProvider) fails the
    GUI test.
- go test -tags nogui ./internal/agent ./internal/gateway ./internal/provider
  ./internal/gui ./internal/tui ./internal/codexcat . in a temp HOME: all ok.
- node --test agent-*.test.cjs (254 pass) and i18n-keys, gui-ja, gui-de,
  click-scroll: all pass.
- gofmt -l is clean.
- go vet -tags nogui on darwin, linux and windows: clean.
- go build, and GOOS=windows go build: ok.
2026-10-09 14:10:13 +08:00
yetone 969e54f23b gateway: a turn on one of Codex's own models logs the reasoning Codex asked for (Karen, Discord #feedback: ChatGPT 账号登录,升级到最新版推理强度直接不显示了) — Codex signed in with ChatGPT sends its own models (gpt-6-astra, gpt-6.1-sol) on to chatgpt.com through /backend-api/codex, and that relay (codexUpstream) wrote its request-log row, its Routing trace and the trace's try without the effort, so the log's 推理强度 column was — on every one. It now records reasoning.effort from the (zstd-decoded) body as it goes on, unchanged, in all three. With the owner's real ChatGPT account in a sandbox magpie, codex exec at xhigh through openai_base_url: the row says openai · chatgpt.com, gpt-5.5, effort xhigh. TestCodexOwnModelLogsEffort (a zstd body at xhigh: the ledger's Effort, the route's and its try's) fails on the old code. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass (TestProvidersAnswerWhileListsComeIn, TestUserPath and TestClaudeSignedOut timed out under load and pass on their own). 2026-10-05 11:04:22 +08:00
Fanbuz c9d0d15b94 fix: 记录网关实际返回的响应 ID (#693) 2026-10-03 22:45:42 +08:00
Zhu Wang 1adb2b571e feat(routing): group requests by session with names and estimated costs (#396)
* feat(routing): group requests by session with names and estimated costs

* fix(routing): address session view review feedback

Preserve Luna Reserve and other header fallbacks for ordinary Codex turn metadata; reuse metadata and the kind across trace and native accounting. Default to By request and persist the grouping choice. Store only token accounting fields in route history while retaining legacy JSON compatibility.

Add regressions for helper precedence, native kind accounting, history compatibility and grouping preferences.
2026-10-01 20:50:15 +08:00
yetone b9895c2ded tests: the gateway's and Devin's tests run on Windows in a home of their own — on Windows os.UserHomeDir reads USERPROFILE, not HOME, so a test that set HOME to a temp dir still found the one USERPROFILE every gateway test shares (and the box's real agents); Devin's CLI keeps its sign-in under APPDATA. Each such test now sets USERPROFILE with HOME (setHome), TestDevinOwnMovesWithPlan sets APPDATA, and the tests whose Claude Code is a shell script skip on Windows, where it can't run and the box's real claude ran instead. Tests only. The gateway suite and TestDevinOwnMovesWithPlan pass on Windows; go test -tags nogui ./... passes on macOS. 2026-10-01 20:26:53 +08:00
c0f3fa012a usage: combine gateway and local session requests with model charts and account labels (#239)
* usage: Requests lists the agents' own session-file calls, put to the vendor and account their files prove, charts them by provider, agent or model, shows what was said, and the tray panel gets a Usage tab

The Usage page's Requests tab now covers requests an agent sends with its own sign-in (Claude Desktop's Code tab and Cowork, Claude Code, Codex), which never pass the gateway, and shows more of every request: why it failed, what was said in it, who it was of.

Requests tab: a strip of four totals (tokens, requests, cost, cache hit rate); the trend of one metric — tokens, cost or requests — as columns by the hour, day or week, told apart by provider, agent or model (both remembered), beside a ranking of the same that is its legend and a way in (a click lists only that provider's or agent's requests; a provider picker sits beside the agent's). The ranking is as tall as the chart and scrolls in itself, with no scrollbar: a slim rail in the card's margin shows how much there is and where it is (its thumb dragged, the rail clicked), and the edge with more beyond it fades; under the chart (860px and narrower) it shows whole. A row opens to its details: the vendor's error type and words, request id, endpoint, and what was said in it (input and output, read from the agent's session file when opened, the call that ended nearest the request — nothing stored). A refresh period (off / 5 s / 10 s / 30 s / 1 min) and refresh-now. The Overview says it counts gateway calls only; Requests and the panel say they count both. The tray panel gets a Usage tab (today / 7 / 30 days, provider picker, four totals, a small chart, top five, "Open Usage"), and is as tall as its tallest tab (#124).

Provider and account of a session-file call: never magpie's "claude" or "codex" subscription. Anthropic's when Claude Desktop's session metadata (not Claude-3p) names the account and organization, with that account's email; OpenAI's when Codex's rollout names a provider that is OpenAI's in config.toml — the built-in "openai", or a named one at OpenAI's address or signed in with the ChatGPT account and no base_url (requires_openai_auth) — with the creator account's email when the file records it. Anything else is "Local session", its recorded provider id and session account kept (CSV: session_provider, session_account). The config read is today's: a file names the provider id only.

Gateway: a failed call keeps the vendor's error text and type, request id and endpoint; a Claude subscription's failure uses the status Claude Code reports (api_error_status). A request turned away before any vendor was asked is logged, marked rejected, listed in Requests and left out of every total. The client's own session header is kept as native_session beside X-Magpie-Session, and a session-file call is matched to a gateway record by request id, then by that session, equal tokens and an end within 2 s, only when unique both ways.

Reading: session-file calls live in the session index main keeps on disk, parsed incrementally and outside its lock (Claude Code, Cowork in both Claude folders, Codex); the usage log is read on from where it was; a page builds the ledger once. Days are counted on calendar dates (DST). CSV gains request_id, endpoint, error_message, error_type, source, session_provider, session_account. i18n: one "Endpoint" (终结点), which a second key had turned for Azure's field.

Tested: go vet ./..., go build (also GOOS=linux/windows, -tags nogui) and go test -tags nogui ./... pass. The whole GUI suite in Chromium and WebKit, en and zh (Playwright 1.62.1): all 393 tests pass. On this computer's files (7 days): 3,330 Claude Desktop calls resolve to Anthropic with the account, 1,991 Codex calls on a named ChatGPT-signed-in provider to OpenAI (620 with the account; older rollouts don't record it), 9 Claude Code CLI calls stay Local session.

Co-authored-by: yetone <yetoneful@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* usage: a session-file call of one of magpie's own Codex or Claude accounts is told as that provider, beside the gateway's calls on it — "OpenAI" and "Codex" (or "Anthropic" and "Claude Code") read as two vendors when they were one subscription

Codex: an official route (above) whose creator account and user are one of magpie's Codex sign-ins (the CLI's own or a saved one) is magpie's "codex", with that account's email as the gateway's rows have it. Claude Desktop (not Claude-3p): an account and organization that are one of magpie's Claude sign-ins is magpie's "claude". Only while magpie has that provider signed in; another account, a rollout with no account recorded, or an ambiguous workspace stays OpenAI or Anthropic, and a relay stays Local session.

Tested: TestSessionCallsOfMagpiesAccountsAreItsProviders (the account matched, another account, none recorded, magpie's account through a relay, Desktop in magpie's and another organization, Claude-3p, magpie signed out) and TestLedgerTellsCodexSessionCallsAsMagpiesCodex (a gateway Codex call and a session call of its account one provider of two calls, another account's OpenAI). On this computer (7 days): 3,439 Claude Desktop calls are magpie's Claude, 626 Codex calls its Codex, 1,322 older Codex rollouts with no account stay OpenAI. go test -tags nogui ./... and the usage GUI tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: 修复请求统计缓存膨胀与会话账号误归属 #239

调用明细改为按会话文件分片保存并限制内存缓存,汇总索引仅保留统计数据;网关日志按需读取。

严格匹配订阅账号与用户 ID,排除自定义渠道、非官方端点覆盖、外部 CODEX_HOME 及关闭的供应商。补齐零 token 失败去重、Codex 原始会话 ID、拒绝标记导出和面板显示修复。

通过全量 Go 测试、静态检查、受影响模块的并发检查、52 项浏览器测试及 macOS/Linux/Windows 构建;使用 35 万条合成调用验证索引体积与内存改善。

* fix: 降低请求统计刷新与写入开销并明确本地账号展示 #239

请求分片改为追加帧和字符串去重,分页复用未变化的紧凑快照,采用 LRU 并移出全局锁内的磁盘读取。缓存 Cowork 目录,补齐同前缀改写检测及崩溃临时文件清理。

本地记录仅显示匹配账号或本地会话,明确官方登录标记与请求路由的区别。默认今日与模型维度,Auto Review 复用共享目录定价并单独标注估价参考。

完整 Go 测试、vet、相关 race 和 52 项浏览器回归通过;提供 2000 文件及四个大会话连续追加的可复现性能对照。

* fix: 优化用量徽标与耗时分级并保护分页边界 #239

官方登录、API、订阅和本地会话采用独立颜色与柔和底色,兼容明暗主题。耗时按 10 秒及 30 秒阈值着色,保留估算标识与原始毫秒提示;无有效耗时显示短横线。

限制分页选取范围,避免超大偏移整数溢出及越界空页的无效堆构造。补充阈值、徽标对比度和极端分页参数回归。

* fix: 将账号与来源徽标分为两行展示 #239

* fix: 提高用量表格模型文字对比度 #239

发送模型和已知实际模型使用主题正文次级色,表头与时间同步加深。保留缺失值弱化、转发提示和本地日志来源说明。Chromium 与 WebKit 的中英文、浅深色主题 10 项界面检查通过。

---------

Co-authored-by: yetone <yetoneful@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 17:42:10 +08:00
Aliceandraper 02d501894b usage: link request accounting to routing history (#361)
Co-authored-by: raper <raper@raperdeMacBook-Air.local>
2026-10-01 16:18:02 +08:00
yetone 3df75514b9 agents: each agent's own model list — under an agent's name on the Agents page, "Showing 5 / 32 models" (or "All 41 models") opens a list to take models out of that agent's picker one by one and put them back (@ChongkaiX on X: 在 magpie 里选哪些模型出现在 Codex 的模型列表里) — until now an agent's list could only be narrowed by whole providers or families (Visible). settings.HiddenModels holds, by agent, the catalog entries taken out, after Visible: a deny list, so a new model is shown. provider.CatalogFor drops them, so the gateway's /models, the agents' files and pickers and Codex's catalog all follow in one place, and catalog.Touched rewrites the agents' files; Codex's own ChatGPT models are dropped from the backend's list too (CodexNativeHidden), and the list's ETag and models_cache tag carry them (CodexListTag) so Codex asks again. The model an agent is set to is marked 在用 and never taken out, on the server as well. The list groups routing groups first, then providers with their logos and on/total, a long group folded; search, 全部/已显示, a group's 全部显示/全部隐藏 on hover, 恢复全部显示; a click on a row applies at once, Esc or a click elsewhere closes it, and nothing scrolls. A renamed provider's hidden models follow it. Tested with agent-models.test.cjs in Chromium and WebKit, English and Chinese; TestHiddenModels (provider), TestCodexModelListHidesOnAgentsPage (gateway) and TestAgentModelsAPI (gui) in sandbox HOMEs. click-scroll, panel-fold, old-webkit, model-pick, menu-scroll, add-button pass; GOOS=linux go vet, linux and windows builds, go test -tags nogui ./... pass. Not tried in the real Wails window or against a real Codex. 2026-09-30 12:44:59 +08:00
Zhaofeng 99a6c0d354 codex: a subscription switched off narrows nothing, its models kept whole (switching the codex provider off left the one picked ChatGPT model as the only one Codex listed) — the codex provider's picks narrow the ChatGPT account's own model list as well as magpie's added models (CodexNativePicked, aed12ac), and ownCodex narrows the picker's OpenAI half the same way. Neither looked at Off, so a provider switched off — which serves no agent anything, by Provider.Off's own promise — still narrowed the account's list to the picks it kept, and a single pick left Codex listing that one model alone. Both now treat a switched-off provider as picking nothing: the account's list is left whole, and the picks stay in providers.json, narrowing again as soon as it is switched on. Tested with a new TestCodexModelListNotNarrowedWhileOff in internal/gateway (a fake backend listing two models; switched off with picks=[gpt-6-sol] both come through, switched on just the pick; fails on main with [gpt-6-sol]) and a new TestCodexOwnModelsNotNarrowedWhileOff in internal/agent (Codex's own picker: both models while off, just the pick while on; fails on main with [gpt-b]). go build -tags nogui ./..., go vet ./internal/agent ./internal/provider ./internal/gateway and go test -tags nogui -count=1 ./... pass (#274) 2026-09-30 12:24:56 +08:00
yetone aed12ac60f codex: the ChatGPT account's own models Codex lists follow the user's picks too (在magpie里把ChatGPT提供商只勾选GPT-6-Sol,codex里还是显示所有模型 — @vemsux) — signed into ChatGPT with magpie as the base URL, Codex asked the backend for its model list and magpie passed every model the account can reach straight through, so picking among them on the codex provider only ever narrowed magpie's own added models, never ChatGPT's. Now the gateway keeps that /models answer to the slugs the user kept (provider.CodexNativePicked, from the codex provider's picks); untouched picks leave the list whole, as before. The dedup that skips a ChatGPT account's models in CodexListed is unchanged — the backend still lists them, now only the kept ones 2026-09-28 19:06:32 +08:00
herrkaefer c46840a0b0 gateway: validate requests before routing Codex models (#99) 2026-09-27 14:46:22 +08:00
yetone a1dd2b1222 routing: a turn on one of Codex's own models (gpt-5.5 and the rest, which go to ChatGPT with Codex's own sign-in) shows in the Routing view's live trace as those on magpie's models do — before, only magpie's were traced, so Codex on its own models showed nothing going on. Asked on Discord 2026-09-26 18:31:46 +08:00
yetone 189c8949ed codex: one of Codex's own models picked while Codex is signed in with an API key OpenAI refuses (one a relay issued, left in ~/.codex/auth.json) failed with OpenAI's bare 401 "Incorrect API key provided" on every turn; the refusal now says it is Codex's own sign-in that was refused and to pick one of magpie's models in Codex or sign Codex in again 2026-09-26 15:14:33 +08:00
yetone 67056512e0 codex: back on one of Codex's own models after another vendor's, the conversation goes on — another vendor's reasoning (an rs_… id with nothing sealed in it, as Volcengine writes it) went on to OpenAI, which keeps nothing (store is false), looked the id up and answered 404 "Item with id 'rs_…' not found" on every turn and compaction; it now stays out, and an item OpenAI still refuses (sealed content it can't verify, an id it doesn't have) is taken out and the rest asked again instead of the session stuck on it 2026-09-26 13:59:01 +08:00
yetone 31aabbce43 provider: a key added or turned on has its models asked for at once - which models a key sees is known only from its own list, and since #76 an off key's isn't asked, so a key turned back on (or a new one) waited for the next Refresh: a relay that hands out a key per group sent it nothing, or every model; and a Codex reasoning item whose content is null is kept for OpenAI like one without content (#75 dropped it as malformed) 2026-09-26 01:07:47 +08:00
herrkaefer fa38ca4a96 codex: omit incompatible reasoning before OpenAI replay (#75) 2026-09-26 01:06:41 +08:00
herrkaefer daaeee95b2 codex: preserve native compaction for built-in models (#65) 2026-09-25 22:12:30 +08:00
yetone 09c635cf03 agents: a model through magpie tells Pi, Crush, omp and Codex how much it holds, and a provider added, edited or removed reaches the model lists agents keep in files of their own — the catalog carried no context window, so Pi took every model through magpie for a 128K one (a CLIProxyAPI's gpt-5.5 holds 922K) and Crush for a 200K one; each model now carries models.dev's input limit, else its context, looked up by bare id as most of the providers serving it give it (a proxy's "openai/gpt-5.4", "gpt-5.4(high)", "glm-4.6:free" find it too; a group holds the least of its members'). And those lists were written only when a model was picked: Codex's magpie-models.json, Pi's models.json, OpenCode's, Crush's, Command Code's, omp's and Hermes' provider blocks and dsh's llm-deepseek entry kept the catalog as it was then, so a provider added later never showed. Saving a provider, a vendor's list fetched anew or models.dev synced now rewrites each one magpie wrote, where it differs, and the app does once at start-up; a Codex signed in to ChatGPT, which asks the gateway, kept its cached list under the backend's ETag, which a change of magpie's never changed — the ETag (and a reply's X-Models-Etag) now carries a tag of magpie's models, and a cache from before a change is aged so the next Codex asks again 2026-09-25 12:32:14 +08:00
yetone bd5bf422ed codex: a ChatGPT account out of allowance gets magpie as a provider of Codex's, and a routing group is named as one in the Codex app's list — signed in through openai_base_url, the Codex app won't send anything once the account has used its allowance up, a magpie model's request too, so magpie is then wired as it is when signed out (model_provider, as the account's own models can't run anyway); and the gateway's model list for the signed-in app named a group after its first member's provider ("z-ai/glm-5.3 · nvidia"), reading as that provider's own model, where it now says routing group, as magpie's other lists do 2026-09-25 06:49:01 +08:00
yetone c3931c91df codex: magpie's models join Codex's own rather than replacing them — signed in (ChatGPT or an API key), Codex keeps its built-in OpenAI provider and sign-in and is pointed at magpie with openai_base_url alone, so its official models still go to OpenAI on the user's own account, its threads (listed per provider) stay together, and the Codex app keeps its model picker; magpie's gateway answers at /backend-api/codex, passing Codex's own models through as they came, serving magpie's (provider/model) itself, and handing out OpenAI's model list with magpie's after it for /model. Compacting a magpie model's conversation is done by that model with Codex's own prompt; Codex's compressed request bodies are read, and usage is counted for both. Not signed in, magpie stays a provider of Codex's as before; a magpie set up that way moves over the next time a magpie model is picked 2026-09-25 02:42:24 +08:00