usage: a Mythos no catalog prices is priced as its Fable (shangyuan0818 on X)

shangyuan0818 on X (Windows, latest): Usage -> Requests shows no price
for claude-mythos-5.2, and Codex subscription requests made hours apart
are priced as cache misses.

Cause (Mythos). No catalog lists claude-mythos-5.2: models.dev's
anthropic has claude-fable-5-2 (8/40, cache 0.2/10) but no Mythos 5.2,
and its only Mythos price is azure's claude-mythos-5, at claude-fable-5's.
So ListPrice, MakerPrice and PricedName found nothing and the row was
unpriced.

Fix. mythosFable maps a Mythos id to the Fable of the same version
(claude-mythos-5.2 -> claude-fable-5.2). Anthropic's docs give Mythos 5.1
"the same ... per-token pricing" as Fable 5.1 ($10/$50, cache reads
$0.25) and Mythos 5 the same as Fable 5. ListPrice, MakerPrice and
PricedName (the row's "priced as" and the Sessions page's price) try it
last, after every price for the Mythos id itself: a catalog's, what
Anthropic told Claude Code (additionalModelCostsCache), a plugin's. A
first version put it in pricedNamesTo, ahead of Claude Code's price, and
TestClaudeAccountListsGatedModels went red in the full suite. That
ordering is what this version fixes.

Codex cache: no change. magpie prices a Codex call from the cached
tokens OpenAI reports (input_tokens_details.cached_tokens, read in
responses.go and chat.go). No time-window guess exists in usage
pricing; the only time rule is gateway routing affinity (chatGPTCold,
1h), which picks an account and prices nothing. Real records on this
Mac (usage.jsonl against ~/.codex/sessions, one account, gpt-6-sol):
- a thread resumed after 25 min: OpenAI reported 186112 of 186330 cached;
- after 748 min (12.5h): OpenAI itself reported 3456 of 30724 cached.
magpie recorded and priced exactly those numbers. A miss hours later is
OpenAI's cache having expired.

Run:
- TestMythosPricedAsItsFable (new): Mythos 5.2 written five ways
  (dots, dashes, case, [1m], anthropic/ prefix) is priced at Fable 5.2's
  through MakerPrice and ListPrice, and PricedName names claude-fable-5.2.
  A listed Mythos 5 keeps its own price, and claude-mythos-9 stays
  unpriced. With mythosFable disabled by hand, 11 of its checks go red.
  Restored, it is green, with TestClaudeAccountListsGatedModels green in
  both cases.
- Real catalog: a throwaway test (not committed) loaded this Mac's
  ~/.cache/magpie models.json and labs.json from today into a sandbox
  HOME and ran on mica. Results:
  - claude-mythos-5.2 and -5-2: 8/40/0.2/10, priced as claude-fable-5.2;
  - claude-mythos-5-1 and 5.1: 10/50/0.25/12.5;
  - claude-mythos-5: 10/50/1/12.5.
- go test -count=1 -timeout 45m ./... on mote at this commit (rebased
  on origin/main 5bd41301b): 100 packages ok. The one red is
  internal/cli TestEveryRouteHasACommandOrIsNamed ("POST /api/warm-all
  has no command"). It comes from 5bd41301b and is filed as #6724.
- Windows (xiaomi-gpu, win-run): go test ./internal/provider/ at this
  commit. TestMythosPricedAsItsFable passes. 17 reds, the same set as
  origin/main 5bd41301b run there alone (main has one more,
  TestUsageReadAndReadAgain). All are filed: #2808, #6024, #6025, #4633,
  #4115/#6068 and #4446.
- gofmt -l: nothing. go vet on mica: darwin, GOOS=linux -tags nogui and
  GOOS=windows ./... all ok before the reorder. After it, the same three
  ran on internal/provider and internal/sessions: ok.

Not tried: the reporter's own Windows usage data. Not covered: a dotted
id with a window mark (claude-mythos-5.2[1m]) is still unpriced, because
catalog.PricedBy doesn't combine the two rewrites even for Fable; that
is filed as #6725.
This commit is contained in:
yetone
2026-11-15 11:50:15 +08:00
parent 5bd41301b9
commit c12ca5e3b7
2 changed files with 91 additions and 0 deletions
+27
View File
@@ -2455,6 +2455,9 @@ func (p Provider) listPriceIn(c priceCats, model string) (catalog.Price, bool, i
if p.pluginFree(model) {
return catalog.Price{}, true, pricedOwn
}
if f, ok := mythosFable(model); ok {
return p.listPriceIn(c, f)
}
return catalog.Price{}, false, pricedOwn
}
@@ -2784,6 +2787,9 @@ func MakerPrice(model string) (catalog.Price, bool) {
return pr, true
}
}
if f, ok := mythosFable(model); ok {
return MakerPrice(f)
}
return catalog.Price{}, false
}
@@ -3254,6 +3260,22 @@ func pricedNamesTo(dst []string, model string) []string {
return out
}
// mythosFable is the Fable of a Mythos id's version (claude-mythos-5.2 ->
// claude-fable-5.2), the price of a Mythos nothing prices
// (shangyuan0818 on X): Anthropic gives Mythos 5.1 Fable 5.1's per-token
// pricing and Mythos 5 Fable 5's, and models.dev's azure lists
// claude-mythos-5 at claude-fable-5's. It is the last place looked, so a
// price for the Mythos itself (a catalog's, what Anthropic told Claude
// Code, a plugin's) always comes first.
func mythosFable(model string) (string, bool) {
l := strings.ToLower(strings.TrimSpace(model))
i := strings.Index(l, "claude-mythos-")
if i < 0 {
return "", false
}
return l[:i] + "claude-fable-" + l[i+len("claude-mythos-"):], true
}
// PricedName is the catalog ID used for a list-price estimate. Prefer a
// directly listed model before falling back to a documented alias.
func PricedName(model string) string {
@@ -3263,6 +3285,11 @@ func PricedName(model string) string {
return name
}
}
if f, ok := mythosFable(model); ok {
if _, ok := MakerPrice(f); ok {
return PricedName(f)
}
}
return n[len(n)-1]
}
+64
View File
@@ -0,0 +1,64 @@
package provider
import (
"os"
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/catalog"
)
// mythosCatalog lists Fable 5 and 5.2, and Mythos 5 at a price of its
// own (models.dev's azure lists it at Fable 5's; here it differs, to tell
// them apart); no catalog lists Mythos 5.2.
const mythosCatalog = `{
"anthropic":{"id":"anthropic","models":{
"claude-fable-5":{"id":"claude-fable-5","cost":{"input":10,"output":50,"cache_read":1,"cache_write":12.5}},
"claude-fable-5-2":{"id":"claude-fable-5-2","cost":{"input":8,"output":40,"cache_read":0.2,"cache_write":10}},
"claude-mythos-5":{"id":"claude-mythos-5","cost":{"input":11,"output":55,"cache_read":1.1,"cache_write":13}}}}}`
// A call to claude-mythos-5.2 showed no price in Usage → Requests
// (shangyuan0818 on X): no catalog lists it. Anthropic prices a Mythos as
// the Fable of its version, so it is priced at claude-fable-5-2's, however
// the id is written; a Mythos a catalog does list keeps its own price.
func TestMythosPricedAsItsFable(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)
os.WriteFile(catalog.CachePath(), []byte(mythosCatalog), 0o644)
catalog.Reset()
t.Cleanup(catalog.Reset)
claude := Provider{ID: "anthropic", Name: "Claude"}
for _, c := range []struct {
id string
in, out float64
}{
{"claude-mythos-5.2", 8, 40},
{"claude-mythos-5-2", 8, 40},
{"Claude-Mythos-5.2", 8, 40},
{"claude-mythos-5-2[1m]", 8, 40},
{"anthropic/claude-mythos-5.2", 8, 40},
{"claude-mythos-5", 11, 55},
} {
if pr, ok := MakerPrice(c.id); !ok || pr.Input != c.in || pr.Output != c.out {
t.Errorf("MakerPrice(%q) = %+v, %v; want $%v / $%v", c.id, pr, ok, c.in, c.out)
}
if pr, ok := claude.ListPrice(c.id); !ok || pr.Input != c.in || pr.Output != c.out {
t.Errorf("ListPrice(%q) = %+v, %v; want $%v / $%v", c.id, pr, ok, c.in, c.out)
}
}
// the row's "priced as" and Sessions' price name the Fable it took
if got := PricedName("claude-mythos-5.2"); got != "claude-fable-5.2" {
t.Errorf("PricedName(claude-mythos-5.2) = %q, want claude-fable-5.2", got)
}
if got := PricedName("claude-mythos-5"); got != "claude-mythos-5" {
t.Errorf("PricedName(claude-mythos-5) = %q, want itself", got)
}
if _, ok := MakerPrice("claude-mythos-9"); ok {
t.Error("claude-mythos-9 priced; no Fable 9 is listed")
}
}