Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(pricing): strip stacked model-name decorations in any order

Claudea9bbb9cefb01
diff --git a/cli/beacon/internal/pricing/lookup.go b/cli/beacon/internal/pricing/lookup.go
index 884057e5..effca5c6 100644
--- a/cli/beacon/internal/pricing/lookup.go
+++ b/cli/beacon/internal/pricing/lookup.go
@@ -144,7 +144,7 @@ var reductions = []struct {
// The model is tried at four spelling rungs -- exact, canonical, dotted version, provider
// prefix (see the Match constants) -- and the first rung with any match decides. If that fails,
// trailing decorations are stripped one at a time (context-window marker, then date snapshot,
-// then effort suffix) and all four rungs are tried again after each. There is no substring,
+// then effort suffix, repeated until none is left) and all four rungs are tried again after each. There is no substring,
// prefix or edit-distance matching: claude-4.5-sonnet is not claude-sonnet-4-5, and a guess
// that prices the wrong model is worse than no price.
//
@@ -162,15 +162,22 @@ func (c *Catalog) Lookup(model string) (Resolution, bool) {
return res, priced
}
current := asymptoteobserve.NormalizeModelName(query)
- for _, red := range reductions {
- reduced := red.re.ReplaceAllString(current, "")
- if reduced == current || reduced == "" {
- continue
- }
- current = reduced
- res.Stripped = append(res.Stripped, red.name)
- if priced, decided := c.matchSpellings(current, &res); decided {
- return res, priced
+ // Passes repeat until none of the reductions applies, because a runtime can stack
+ // decorations in any order: claude-sonnet-4-6-20260101-high only exposes its date once the
+ // effort suffix is off. Every strip shortens the name, so the loop ends.
+ for stripped := true; stripped; {
+ stripped = false
+ for _, red := range reductions {
+ reduced := red.re.ReplaceAllString(current, "")
+ if reduced == current || reduced == "" {
+ continue
+ }
+ current = reduced
+ stripped = true
+ res.Stripped = append(res.Stripped, red.name)
+ if priced, decided := c.matchSpellings(current, &res); decided {
+ return res, priced
+ }
}
}
res.Stripped = nil
diff --git a/cli/beacon/internal/pricing/lookup_test.go b/cli/beacon/internal/pricing/lookup_test.go
index c23cfe30..53bd7cf1 100644
--- a/cli/beacon/internal/pricing/lookup_test.go
+++ b/cli/beacon/internal/pricing/lookup_test.go
@@ -62,6 +62,10 @@ func TestLookupRealModelStrings(t *testing.T) {
{"gpt-5.5-high", "gpt-5.5", MatchExact, []string{StrippedEffortSuffix}},
{"gpt-5-codex-high", "gpt-5-codex", MatchExact, []string{StrippedEffortSuffix}},
{"claude-sonnet-4-5-thinking", "claude-sonnet-4-5", MatchExact, []string{StrippedEffortSuffix}},
+ // Decorations stack in whatever order a runtime appends them: an effort suffix on a dated
+ // snapshot comes off first, and the date it exposes is stripped on the next pass.
+ {"claude-sonnet-4-6-20260101-high", "claude-sonnet-4-6", MatchExact, []string{StrippedEffortSuffix, StrippedDateSnapshot}},
+ {"claude-sonnet-4-6-20260101-thinking[1m]", "claude-sonnet-4-6", MatchExact, []string{StrippedContextWindow, StrippedEffortSuffix, StrippedDateSnapshot}},
// Gemini CLI.
{"gemini-2.5-pro", "gemini-2.5-pro", MatchExact, nil},
{"gemini-3.1-pro-preview", "gemini-3.1-pro-preview", MatchExact, nil},