Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
usage: Codex's auto-review through a ChatGPT sign-in costs nothing (silverzhou)
yetonec201fe226600
diff --git a/docs/subsystems/providers-accounts.md b/docs/subsystems/providers-accounts.mdindex df742e254..a3049c777 100644--- a/docs/subsystems/providers-accounts.md+++ b/docs/subsystems/providers-accounts.md@@ -54,6 +54,7 @@ keys and accounts per request is in [Gateway routing and fallback](gateway-routi| An endpoint's catalog | A key's provider with no catalog of its own (none named, none from a preset) is priced from the models.dev catalog whose `api` is one of its endpoints (`EndpointCatalog`, `catalog.AtEndpoint`; a trailing slash and case don't count, and an Anthropic base, kept as its root, is also matched with its `/v1`). Only when exactly one catalog is at that address, and it isn't a plan's (an id with `-plan`, or a `membershipCatalogs` one): a plan lists its membership's $0, and two catalogs at one address can't be told apart. A subscription's account never gets one. A provider at AMD's own endpoint is priced from `amd`, which lists Qwen3.8-27B at $0, a price, where its maker sells no such model and it had none (#2052); a relay's endpoint matches nothing and its model stays unpriced, never priced at a reseller's guess. `magpie model price` names the catalog, and says how to give a price when none is known. | [`models.go`](../../internal/provider/models.go), [`catalog.go`](../../internal/catalog/catalog.go) || A membership's $0 catalog | models.dev lists every model of Kimi Code's plans (`kimi-code-plan-global`, `kimi-code-plan-cn`) and of Xiaomi MiMo's Token Plans (`xiaomi-token-plan-cn`, `-sgp`, `-ams`) at $0: what the membership charges per token, not what the model costs. `membershipCatalogs` are never read for a price (`priceCatalogs`, `makerPriceCatalogs`), so a Xiaomi MiMo model is priced at `xiaomi`'s list price at every region, and each region of the preset names its own catalog, pay as you go `xiaomi` alone (#1873). A Kimi Code provider's model is priced at the Kimi API model it is (`kimiCodeAPI`, from Kimi Code's docs: k3 and k3-256k are kimi-k3, kimi-for-coding-highspeed is kimi-k2.7-code-highspeed), and kimi-for-coding (K2.8 Preview, not on the API) is unpriced rather than free (#1370). The alias is Kimi Code's alone (`kimiCodePlans`): a relay's own `k3` keeps its own price. A catalog other than these that lists a model at $0 still prices it at $0: models.dev has truly free models (nvidia, modelscope). The Requests list names the API model it was priced as (`PricedNameFor`). | [`models.go`](../../internal/provider/models.go) || A plugin's own price | A model no catalog prices (models.dev has no vendor's own model: Devin's SWE-2 and SWE-1.7 Lightning, Cursor's auto, Qoder's efficient) is priced at what its plugin lists it at (`ListPrice` → `pluginListPrice`, `plugin.Model.Cost`, read by `pluginPrice`: an input or output above 0, OpenCode's 0 being none), else at $0 when the plugin says the plan serves it free (`pluginFree`, `plugin.Model.Free`: Devin's Free cost tier, Qoder's and WorkBuddy's x0). Both come after every catalog, so a price a catalog gives is kept over the plugin's. Devin's plugin (0.1.18) lists each paid model at the price Devin's GetCliModelConfigs gives it (input, cached input and output per 1M tokens); a moved Devin user's calls on Devin's own models had no cost on Usage before (太陽と向日葵 on Discord, `TestPluginFreeModelCostsNothing`). A plugin that gives no price and doesn't say free leaves the model unpriced. | [`models.go`](../../internal/provider/models.go), [`plugins.go`](../../internal/provider/plugins.go), [`providers.go`](../../internal/plugin/providers.go) |+| Codex's free auto-review | OpenAI made Codex's Auto-review free for users signed in through a ChatGPT account (silverzhou on Discord), so a `codex-auto-review` call through the Codex subscription is priced at nothing (`ListPrice` → `codexReviewFree`, `provider.ChatGPTReviewFree`), not at GPT-5.6 Luna's price (`pricedNames`), and the Requests list names no model it is priced as (`PricedNameFor`). Not on a Free plan, where it spends the allowance (cybercaius), read from the plan Codex is signed in to now; a Codex signed out since counts as a paid plan, as the gateway's caps take it (`freeOnChatGPT`). The same model through an API key, the ChatGPT API subscription or a relay, and a review that followed the session to another model, keep their price; a price the user set wins. Every call is priced as it is read, so rows logged before are free too; the price views' cache keys on each account's plan (`usagePriceCacheKey`). Guarded by `TestAutoReviewFreeOnChatGPTSignIn` and `usage.TestAutoReviewFreeOnChatGPT`. || A lab's models | models.dev keeps two catalogs: `api.json`, each provider's models with that host's prices, and `models.json`, each lab's models with only what is the model's on every host (name, window, reply limit, thinking, inputs, release), no price. `Sync` keeps the second beside the first as `labs.json` (`LabsPath`, `syncLabs`: best effort, through a rename, a failed fetch keeping the last; a catalog with none beside it is `Stale` once a process, so it comes at the next look). A model only a lab lists, no provider (models.dev took the gated Claude Mythos 5.1 out of anthropic's list in #11327 and kept its lab file), is voted into the same tables as a listed one (`loadGen`, `labs`), so `ContextOf`, `OutputOf`, `NameOf`, `Thinks`, `SeesImages` and every entry built on them know it wherever a vendor's or an account's list has it; a thinking one with no levels takes the levels of the newest of its family a provider gives them (`labKinEfforts`: Mythos 5.1 takes Mythos 5's). A model a provider lists keeps what providers say of it. `catalog.Describe` builds a model from these for a list that names an id alone. `TestLabOnlyModelIsKnown`, `TestLabsLeaveListedModels`, `TestSyncKeepsLabs`, `TestAnthropicKeyGatedModelDescribed` (iebb on Discord). | [`labs.go`](../../internal/catalog/labs.go), [`catalog.go`](../../internal/catalog/catalog.go) || A Claude account's models | magpie never asks Anthropic with a Claude sign-in, so a Claude account's list is models.dev's anthropic list and what Anthropic told the account's Claude Code beyond it. Claude Code keeps that in its `.claude.json` from its own bootstrap: `additionalModelOptionsCache` (models its /model picker offers beyond its own; a `null` value or a `disabled` one is not a model), `modelAccessCache` (`entitled` per API id) and `additionalModelCostsCache` (Anthropic's prices). `claudeModels` reads the file of Claude Code's own sign-in (`claudeProfilePath`) and of each saved account's directory (`claudeAccountDir`), through `filememo`, and adds each model none of them lists, described by `catalog.Describe` and priced as Anthropic told it. `Account.Lists` for a Claude account goes by its own file (`claudeLists`: the saved directory's, or Claude Code's own when its `oauthAccount` is that account, the one Anthropic answered last): a model it isn't entitled to is out, so routing tries the accounts entitled to a gated model first; with no file, every model is taken to be in, as before. `ListPrice` of a provider whose catalogs include anthropic falls back to that price after every catalog (`claudeCodePrice`). The agent's own Claude Code model picker (`claudeOwn`) offers what `ClaudeCodeModels` gives for the account signed in here; a WSL distro's keeps the catalog's. Not done: a Claude Code that never started on a saved account has no file, so its gated models show only once it has run there. `TestClaudeAccountListsGatedModels`. | [`claude_code_models.go`](../../internal/provider/claude_code_models.go), [`account.go`](../../internal/provider/account.go), [`codex_models.go`](../../internal/provider/codex_models.go), [`claude.go`](../../internal/agent/claude.go) || A key's own windows | A sub2api key given a spending limit per 5 hours, day or 7 days answers its `/v1/usage` with `rate_limits` and no `remaining` (`readSub2APIKeyLimits`). With the Balance URL set to it, the key's card shows them as the windows *5 hours*, *1 day*, *7 days*, in USD, beside a balance field the user wrote; *Check balance* and `magpie provider show` give what its fullest window has left (`Balance`). A Balance URL at an account query left without its token (a sub2api panel's `/api/v1/user/profile`, new-api's `/api/user/self`, after the token was removed) asks the same panel's query for the key instead, the saved URL untouched (`keyQueryOf`, `BalanceQuery`), unless the user's Headers carry an Authorization or Cookie of their own. A Balance URL of the user's own is asked with GET, or with POST and no body when the provider's `BalanceMethod` says so (#2368: an endpoint that answers only a POST; the editor's GET/POST beside the URL, `balance.method=` on the command line); any other method is refused before anything is sent (`balanceMethodOf`). `KeyAllowance` gives routing the same windows: never waited for, read in the background at most once a minute, a failed read keeping the last, and seeded from the card's last reading (`quotas.json`) after a restart. A key bought as a plan (Kimi Code, GLM Coding Plan and Z.ai, MiniMax Coding Plan, OpenCode Go, Command Code, Ollama Cloud: `planQuotaSourceOf`) gives routing its card's windows the same way (`planKeyWindows`, Zhipu's team quota behind a key with none of its own); the Usage page's read of its card is taken at once (`noteKeyAllowance`), and a key there that turns out pay-as-you-go, with no windows, is asked again only every 30 minutes (`keyNoWindowsAge`). A Command Code plan's key has its month of credits as a *Credits* window beside the 5-hour and weekly ones, as the signed-in subscription's card has (`cmdKeyWindows`, #2451): billing/credits leaves the plan out, so it is the key's billing/subscriptions plan, asked at most every ten minutes and the last one kept while it can't be read; the same reply's period end is the Credits window's reset, left off once it has passed (#2454); a key whose plan was never read has its two windows alone. Ollama Cloud's `ollama.com/api/balance` (#1888, `readOllamaPlan`) tells the plan's included allowance as one window in USD, *Month* when its period is a month long, renewing at `period.until`, and Aside while credits bought on top are left; those credits are the key's balance card (`readOllamaCredits`), and a reply that names none has no balance card rather than $0. StepFun's Step Plan is read through a platform sign-in, not the key, and isn't one of them: the sign-in is the provider's own, kept by provider id in `stepfun-auth.json` (two StepFun providers on one site can be two accounts, #2384), one card per signed-in provider; a file from before that, kept by site, is given on read to the StepFun providers on that site (`stepfunBySite`), and copies of one sign-in are renewed together. Nor are Volcengine Ark's Coding Plan and Agent Plan (#1427): their 5-hour, weekly and monthly windows are told only to the account's access key (`AccessKeyID`, `SecretAccessKey`), asked of `open.volcengineapi.com` (`GetCodingPlanUsage`, `GetAFPUsage`) and signed as Volcengine's own SDK signs (`volcSign`), so they are cards on the Usage page (`volcPlanQuotas` in `PlanQuotas`), never routing's windows. Nor is Tencent Cloud's Token Plan 企业版 (#1574): what a team plan has used of its cycle's credits (专业套餐) or tokens (轻享套餐) is told only to the account's SecretId and SecretKey (kept as `AccessKeyID`, `SecretAccessKey`), asked of `tokenhub.tencentcloudapi.com` (`DescribeTokenPlanList`, `DescribeTokenPlan`, version 2026-03-22) and signed TC3-HMAC-SHA256 (`tc3Sign`), one card per team plan (`tencentPlanQuotas`). | [`sub2api_usage.go`](../../internal/provider/sub2api_usage.go), [`key_allowance.go`](../../internal/provider/key_allowance.go), [`volcengine_usage.go`](../../internal/provider/volcengine_usage.go), [`tencent_usage.go`](../../internal/provider/tencent_usage.go) |diff --git a/internal/gateway/codex_memory.go b/internal/gateway/codex_memory.goindex b346a2832..7cc97d425 100644--- a/internal/gateway/codex_memory.go+++ b/internal/gateway/codex_memory.go@@ -2,7 +2,6 @@ package gatewayimport ("net/http"- "strings""time""github.com/yetone/magpie/internal/access"@@ -43,14 +42,9 @@ func isReviewCall(kind, asked string) bool {}// freeOnChatGPT says whether a call on model by a ChatGPT account on plan-// is free, counted in none of its usage windows: Codex's reviewer model,-// codex-auto-review, since OpenAI made Auto-review free for ChatGPT-// sign-ins on 2026-10-06 (#1593, hywang1230), but not on a Free plan,-// where cybercaius on Discord measured it spending the allowance. A review-// run on another model, or through an API key, is counted as any call.-func freeOnChatGPT(model, plan string) bool {- return strings.EqualFold(strings.TrimSpace(model), "codex-auto-review") && !strings.EqualFold(strings.TrimSpace(plan), "free")-}+// is free (provider.ChatGPTReviewFree, which the Usage page's prices+// follow too).+func freeOnChatGPT(model, plan string) bool { return provider.ChatGPTReviewFree(model, plan) }// codexMemoryStandIn is the model a Codex memory call goes to when magpie// knows none by the name it came with (#742): Codex writes anddiff --git a/internal/provider/codex_price_test.go b/internal/provider/codex_price_test.goindex a799a327a..ed14983fa 100644--- a/internal/provider/codex_price_test.go+++ b/internal/provider/codex_price_test.go@@ -4,8 +4,10 @@ import ("os""path/filepath""testing"+ "time""github.com/yetone/magpie/internal/catalog"+ "github.com/yetone/magpie/internal/settings")func TestAutoReviewUsesSharedCatalogPrice(t *testing.T) {@@ -43,3 +45,80 @@ func TestAutoReviewUsesSharedCatalogPrice(t *testing.T) {t.Fatal("missing catalog price must remain unknown")}}++// OpenAI made Auto-review free for every user signed in through a ChatGPT+// account (silverzhou on Discord, thsottiaux's "Day 2.1"): Codex's+// codex-auto-review through the Codex subscription costs nothing in the+// estimates, but not on a Free plan, where it spends the allowance+// (cybercaius), nor through anything that isn't a ChatGPT sign-in.+func TestAutoReviewFreeOnChatGPTSignIn(t *testing.T) {+ home := signIn(t) // a Pro plan+ if err := os.MkdirAll(filepath.Dir(catalog.CachePath()), 0700); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(catalog.CachePath(), []byte(`{"openai":{"id":"openai","models":{`++ `"gpt-5.6-luna":{"id":"gpt-5.6-luna","cost":{"input":3,"output":7,"cache_read":1}}}}}`), 0600); err != nil {+ t.Fatal(err)+ }+ catalog.Reset()+ t.Cleanup(catalog.Reset)+ s := settings.Load()+ price := func(prov, model string) catalog.Price {+ t.Helper()+ pr, ok := EffectivePriceIn(s, prov, model)+ if !ok {+ t.Fatalf("%s/%s: no price", prov, model)+ }+ return pr+ }+ if pr := price("codex", "codex-auto-review"); pr.Cost(1e6, 1e6, 1e6, 0) != 0 {+ t.Errorf("auto-review on a Pro sign-in priced %+v", pr)+ }+ if pr := price("codex", " Codex-Auto-Review "); pr.Cost(1e6, 1e6, 0, 0) != 0 {+ t.Errorf("auto-review spelled otherwise priced %+v", pr)+ }+ if got := PricedNameFor("codex", "codex-auto-review"); got != "codex-auto-review" {+ t.Errorf("a free call said to be priced as %q", got)+ }+ // a review that followed the session, or ran on Codex's other models+ if pr := price("codex", "gpt-5.6-luna"); pr.Input != 3 {+ t.Errorf("codex gpt-5.6-luna %+v", pr)+ }+ // the same model through anything else is OpenAI's list price+ for _, prov := range []string{"openai", ChatGPTAPIID, "relay"} {+ if pr := price(prov, "codex-auto-review"); pr.Input != 3 || pr.Output != 7 {+ t.Errorf("%s auto-review %+v", prov, pr)+ }+ }+ // what the user set wins+ two, four, zero := 2.0, 4.0, 0.0+ s.ModelPrices = map[string]settings.ModelPrice{"codex/codex-auto-review": {Input: &two, Output: &four, CacheRead: &zero, CacheWrite: &zero}}+ if pr := price("codex", "codex-auto-review"); pr.Input != 2 {+ t.Errorf("the user's price lost: %+v", pr)+ }+ s.ModelPrices = nil++ // a Free plan spends its allowance on it: priced as gpt-5.6-luna+ writeFile(t, filepath.Join(home, ".codex", "auth.json"), map[string]any{+ "auth_mode": "chatgpt",+ "tokens": map[string]any{+ "id_token": fakeJWT(map[string]any{"email": "[email protected]", "https://api.openai.com/auth": map[string]any{"chatgpt_plan_type": "free", "chatgpt_account_id": "acct-1"}}),+ "access_token": fakeJWT(map[string]any{"exp": float64(time.Now().Add(time.Hour).Unix())}),+ "refresh_token": "r", "account_id": "acct-1",+ },+ })+ forgetAccountCaches()+ if pr := price("codex", "codex-auto-review"); pr.Input != 3 || pr.Output != 7 {+ t.Errorf("auto-review on a Free plan priced %+v", pr)+ }+ if got := PricedNameFor("codex", "codex-auto-review"); got != "gpt-5.6-luna" {+ t.Errorf("Free plan's review priced as %q", got)+ }++ // signed out since: the subscription's calls were a ChatGPT sign-in's+ os.Remove(filepath.Join(home, ".codex", "auth.json"))+ forgetAccountCaches()+ if pr := price("codex", "codex-auto-review"); pr.Cost(1e6, 1e6, 0, 0) != 0 {+ t.Errorf("auto-review of a signed-out Codex priced %+v", pr)+ }+}diff --git a/internal/provider/codex_review_free.go b/internal/provider/codex_review_free.gonew file mode 100644index 000000000..54e1d886b--- /dev/null+++ b/internal/provider/codex_review_free.go@@ -0,0 +1,38 @@+package provider++import "strings"++// CodexAutoReview is the reviewer model of OpenAI's that Codex asks its+// auto-review of an approval (the guardian) on.+const CodexAutoReview = "codex-auto-review"++// ChatGPTReviewFree says whether a call on model by a ChatGPT account on+// plan is free, counted in none of its usage windows and charged nothing:+// Codex's reviewer model, codex-auto-review, since OpenAI made Auto-review+// free for every user signed in through a ChatGPT account (2026-10-06,+// #1593, hywang1230; thsottiaux's "Day 2.1"), but not on a Free plan,+// where cybercaius on Discord measured it spending the allowance. A+// review run on another model (one that follows the session, or a stand-in+// magpie routes it to), or through an API key, is a call like any other.+func ChatGPTReviewFree(model, plan string) bool {+ return strings.EqualFold(strings.TrimSpace(model), CodexAutoReview) && !strings.EqualFold(strings.TrimSpace(plan), "free")+}++// codexReviewFree says whether a call on model through p costs nothing:+// p is the Codex subscription, which only ever holds ChatGPT sign-ins (an+// API key's auth.json is no account of it, codexAccount), and the call is+// one ChatGPTReviewFree. The plan is the one Codex is signed in to now; a+// Codex magpie can't read the plan of, or one signed out since the call,+// is taken as a paid plan, as the gateway's caps take it (capHeld). The+// ChatGPT API subscription (chatgpt-api) is not covered: OpenAI said it of+// Codex's own sign-in, not of its API.+func (p Provider) codexReviewFree(model string) bool {+ if p.ID != "codex" || p.Account != nil && p.Account.Agent != "codex" {+ return false+ }+ plan := ""+ if p.Account != nil {+ plan = p.Account.Plan+ }+ return ChatGPTReviewFree(model, plan)+}diff --git a/internal/provider/kimi_code_price_test.go b/internal/provider/kimi_code_price_test.goindex 411aa0910..b87b4b6cd 100644--- a/internal/provider/kimi_code_price_test.go+++ b/internal/provider/kimi_code_price_test.go@@ -103,7 +103,8 @@ func TestKimiCodeListPrice(t *testing.T) {if got := PricedNameFor("relay", "k3"); got != "k3" {t.Errorf("PricedNameFor(relay, k3) = %q", got)}- if got := PricedNameFor("codex", "codex-auto-review"); got != PricedName("codex-auto-review") {+ // free on a ChatGPT sign-in, so priced as nothing else (codexReviewFree)+ if got := PricedNameFor("codex", "codex-auto-review"); got != "codex-auto-review" {t.Errorf("PricedNameFor(codex, codex-auto-review) = %q", got)}}diff --git a/internal/provider/models.go b/internal/provider/models.goindex c85c53174..e23386006 100644--- a/internal/provider/models.go+++ b/internal/provider/models.go@@ -1841,12 +1841,14 @@ var makerCatalogs = sync.OnceValue(func() []string {// account is at Anthropic's. A remote magpie's is what that magpie counts// the model at, as its list says (remotePrice). A model no catalog prices// is at the price its plugin lists it at (pluginListPrice), else, when the-// plugin says the plan serves it free, costs nothing (pluginFree).+// plugin says the plan serves it free, costs nothing (pluginFree). Codex's+// auto-review through the Codex subscription costs nothing too, as OpenAI+// serves it a ChatGPT sign-in (codexReviewFree).func (p Provider) ListPrice(model string) (catalog.Price, bool) {if pr, ok := p.remotePrice(model); ok {return pr, true}- if p.clineFreeModel(model) || p.kiloFreeModel(model) {+ if p.clineFreeModel(model) || p.kiloFreeModel(model) || p.codexReviewFree(model) {// served at no cost: not at the price of the model it is free ofreturn catalog.Price{}, true}@@ -2223,6 +2225,9 @@ func priceOf(s settings.Settings, p Provider, known bool, model string) (catalog}}if !known {+ if p.codexReviewFree(model) { // signed out since: still a ChatGPT sign-in's+ return catalog.Price{}, true+ }if pr, ok := MakerPrice(model); ok {return pr, true}@@ -2362,7 +2367,14 @@ func PricedName(model string) string {// PricedNameFor is PricedName for a call to that provider: a Kimi Code// membership's k3 is priced as the API's kimi-k3 (kimiCodeAPI).func PricedNameFor(providerID, model string) string {- if p, ok := byIDOrWas(providerID); ok && p.kimiCodeMember() {+ p, ok := byIDOrWas(providerID)+ if !ok {+ p = Provider{ID: providerID}+ }+ if p.codexReviewFree(model) {+ return model // free, not priced as another model (codexReviewFree)+ }+ if ok && p.kimiCodeMember() {if id, ok := kimiCodeAPI[strings.ToLower(strings.TrimSpace(model))]; ok {return id}diff --git a/internal/usage/codex_review_free_test.go b/internal/usage/codex_review_free_test.gonew file mode 100644index 000000000..e70a042cd--- /dev/null+++ b/internal/usage/codex_review_free_test.go@@ -0,0 +1,73 @@+package usage++import (+ "math"+ "os"+ "path/filepath"+ "testing"+ "time"++ "github.com/yetone/magpie/internal/catalog"+)++// silverzhou on Discord: OpenAI made Codex's Auto-review free for users+// signed in through a ChatGPT account, and the Usage page still counted+// it at GPT-5.6 Luna's price. A codex-auto-review call through the Codex+// subscription is now priced at nothing, rows logged before the change+// too (they are priced as they are read); the same model through an API+// key, and a review that followed the session to another model, are+// priced as before. The key limits' cost counts the same (NewCoster).+func TestAutoReviewFreeOnChatGPT(t *testing.T) {+ home := t.TempDir()+ t.Setenv("HOME", home)+ t.Setenv("USERPROFILE", home)+ t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))+ t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))+ os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o755)+ if err := os.WriteFile(catalog.CachePath(), []byte(`{"openai":{"id":"openai","models":{`++ `"gpt-5.6-luna":{"id":"gpt-5.6-luna","cost":{"input":3,"output":7,"cache_read":1}},`++ `"gpt-5.6":{"id":"gpt-5.6","cost":{"input":5,"output":20,"cache_read":0.5}}}}}`), 0o644); err != nil {+ t.Fatal(err)+ }+ catalog.Reset()+ t.Cleanup(catalog.Reset)+ in, out, cached := 40_000, 2_000, 100_000+ luna := (float64(in)*3 + float64(out)*7 + float64(cached)*1) / 1e6+ gpt := (float64(in)*5 + float64(out)*20 + float64(cached)*0.5) / 1e6+ now := time.Now()+ calls := []struct {+ prov, model, asked string+ want float64+ }{+ {"codex", "codex-auto-review", "codex-auto-review", 0},+ {"openai", "codex-auto-review", "codex-auto-review", luna},+ {"codex", "gpt-5.6", "codex-auto-review", gpt}, // followed the session+ {"codex", "gpt-5.6-luna", "gpt-5.6-luna", luna},+ }+ for i, c := range calls {+ Append(Record{Time: now.Add(-time.Duration(len(calls)-i) * time.Minute), Agent: "codex", Provider: c.prov, Model: c.model, Requested: c.asked,+ Kind: "guardian", Input: in, Output: out, CacheRead: cached, Status: 200})+ }+ rows, sum, _ := Ledger(Month, Filter{})+ if len(rows) != len(calls) {+ t.Fatalf("rows %d", len(rows))+ }+ var total float64+ for i, c := range calls {+ r := rows[len(calls)-1-i]+ if r.Provider != c.prov || r.Model != c.model || !r.Priced || math.Abs(r.Cost-c.want) > 1e-9 {+ t.Errorf("%s/%s: priced=%v cost=%v, want %v", c.prov, c.model, r.Priced, r.Cost, c.want)+ }+ total += c.want+ }+ if s := Summarize(Month); s.Unpriced != 0 || math.Abs(s.Cost-total) > 1e-9 || math.Abs(sum.Cost-total) > 1e-9 {+ t.Errorf("summary %v (unpriced %d), ledger %v; want %v", s.Cost, s.Unpriced, sum.Cost, total)+ }+ cost := NewCoster()+ if c, ok := cost(Record{Provider: "codex", Model: "codex-auto-review", Input: in, Output: out}); !ok || c != 0 {+ t.Errorf("key limit counts a free review at %v (%v)", c, ok)+ }+ if c, ok := cost(Record{Provider: "openai", Model: "codex-auto-review", Input: in, Output: out}); !ok || c == 0 {+ t.Errorf("key limit counts an API key's review at %v (%v)", c, ok)+ }+}diff --git a/internal/usage/summary_cache.go b/internal/usage/summary_cache.goindex cea386c32..fdb0b8060 100644--- a/internal/usage/summary_cache.go+++ b/internal/usage/summary_cache.go@@ -143,6 +143,11 @@ func usagePriceCacheKey(now time.Time) string {fmt.Fprint(h, string(prices), string(aliases), string(usageAliases))for _, current := range provider.All() {fmt.Fprintf(h, "%q:%q:%v:%t:%t:%t;", current.ID, current.Where(), current.Catalogs(), current.IsPlugin(), current.Account == nil, current.Key != "")+ if current.Account != nil {+ // a plan prices calls too: Codex's auto-review is free on a+ // paid ChatGPT plan only (provider.ChatGPTReviewFree)+ fmt.Fprintf(h, "%q;", current.Account.Plan)+ }fmt.Fprint(h, statKey(catalog.LivePath(current.ID)))}meta += fmt.Sprintf("|%x", h.Sum(nil))