mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 02:39:13 +00:00
Merge pull request #1048 from getagentseal/fix/mimo-alias-landing
fix(models): alias bare MiMo 2.5 ids to the LiteLLM Xiaomi rows (lands #1042 + review fixes)
This commit is contained in:
commit
0290c3ee49
3 changed files with 96 additions and 16 deletions
|
|
@ -33,6 +33,7 @@
|
|||
- **The resident `codeburn serve` child.** The first real panel request is also the cache warm-up, so startup never runs an artificial warm-up query beside a duplicate one-shot child; each served command carries its own read-only option allowlist, and anything outside it falls back to a normal spawn; the child exits when its stdin closes, so it can never outlive the app. Requests whose response exceeds the 16 MiB frame limit still replace the child, but that deliberate kill no longer spends the resident's unexpected-death budget. (#972)
|
||||
|
||||
### Fixed
|
||||
- **MiMo sessions price from the LiteLLM Xiaomi rows, and MiMo v2 Flash no longer crashes the display path.** Hermes / Xiaomi token-plan sessions store the bare id (`mimo-v2.5-pro`, `mimo-v2.5`) while LiteLLM namespaces its row (`xiaomi/…`), so those models reported $0. They now alias to the existing snapshot rows — no invented rate, and `kimi-k3` still has none — which means a session Hermes left costless is priced from the shared tables and carries the estimated marker, exactly as `mimo-v2-flash` already did. The same change fixes a **pre-existing** crash that this alias did not introduce: the shipped `mimo-v2-flash -> xiaomi/mimo-v2-flash` alias already cycled through display-name resolution — strip the namespace, alias it back, take the leaf, repeat — so `getShortModelName` blew the stack on any real MiMo v2 Flash session and took every surface that names a model down with it, the `models` table included. Display-name resolution is now cycle-safe, and the `mimo-v2-flash` and `mimo-v2.5` rows are named rather than shown as raw slugs.
|
||||
- **A date-ranged run no longer republishes the month shards it never read.** A scoped load leaves an out-of-range month on disk, so the files it holds have no visible cache entry and the reconcile re-parses them — re-deriving the entry the shard already stores. That re-parse marked the unloaded month dirty, and the save merged and republished it under a fresh nonce name on every single run, byte-identical content and all, so a repeated `codeburn status --format json` churned old months (on a real corpus: claude/2026-03, cursor/2026-02 and warp/2026-03 renamed every run) and left the retired shards for the sweeper. A merge into an unloaded month that neither adds, changes nor removes an entry now keeps the published shard, so unchanged months keep their names and their bytes. (#1032)
|
||||
- **`models` and `audit` no longer show two identical `Grok 4.5` rows.** `grok-4.5-build` — the Grok Build harness's variant id — fell into the `grok-4.5` display entry by prefix, and since rows bucket by model id, not display name, the two came out as visually identical rows with different numbers. The variant now shows as `Grok 4.5 (build)`. Display only: no id is rewritten and no cost moves. (#1029)
|
||||
- **An upgrade no longer loses history for days whose transcripts have only PARTLY aged out.** The never-lose contract carried a cached (day, provider) slice forward only when the re-derivation found NOTHING for it, but transcripts expire per FILE rather than per day: on a day whose sources are mostly gone, a handful of turns from surviving later files still bucket onto it, so the fresh slice came back non-empty but truncated and REPLACED the full cached one. On a real cache upgrading from the last shipped daily-cache version, 2026-07-16 fell from $1,685.17 / 12,530 calls to $385.44 / 560 calls, and 13 days lost $2,765.75, 19,209 calls and 520 sessions in total. A fresh slice now replaces a settled baseline slice only when it carries at least as many CALLS - the same or more evidence; fewer calls means the source set demonstrably lost data, and the baseline is kept whole. The comparison is on calls alone: cost and tokens are re-priced accounting on the same evidence, which is exactly what a legitimate re-derivation changes (the Grok accounting fix keeps its per-day calls and is unaffected), and session counts drift down by a few on days whose sources are entirely intact. Days inside a 7-day settle window stay authoritative - their session files are still on disk, so a shrink there is a real change rather than expiry. The trade-off is deliberate and matches the direction this cache has always chosen: a future fix that legitimately REDUCES calls on a settled day keeps the older, higher value until that day is re-derived at an equal or greater call count. The timezone-change re-derive gets the exact form of the same rule - what the fresh parse can no longer explain under the old bucketing is added on top of the fresh slice instead of being dropped - and the cross-file adoption union is unchanged, where the newer schema still wins per (day, provider).
|
||||
|
|
|
|||
|
|
@ -297,6 +297,10 @@ const BUILTIN_ALIASES: Record<string, string> = {
|
|||
'k3-agent': 'kimi-k3',
|
||||
'k2d6-agent': 'kimi-k2p6',
|
||||
'mimo-v2-flash': 'xiaomi/mimo-v2-flash',
|
||||
// Hermes / Xiaomi token-plan sessions store the bare id. LiteLLM's row is
|
||||
// namespaced. Same class as mimo-v2-flash above — do not invent a rate.
|
||||
'mimo-v2.5-pro': 'xiaomi/mimo-v2.5-pro',
|
||||
'mimo-v2.5': 'xiaomi/mimo-v2.5',
|
||||
'kat-coder-pro-v1': 'kwaipilot/kat-coder-pro',
|
||||
// Cursor emits dot-version tier-last names plus tier/reasoning suffixes
|
||||
// that LiteLLM does not index (`-high`, `-low`, `-medium`, `-thinking`,
|
||||
|
|
@ -956,6 +960,8 @@ const SHORT_NAMES: Record<string, string> = {
|
|||
// table, the same way it handles `accounts/fireworks/models/<slug>`.
|
||||
'qwen3.7-max': 'Qwen 3.7 Max',
|
||||
'mimo-v2.5-pro': 'MiMo v2.5 Pro',
|
||||
'mimo-v2.5': 'MiMo v2.5',
|
||||
'mimo-v2-flash': 'MiMo v2 Flash',
|
||||
// Both spellings occur in the wild: OpenRouter gap-filled keys are lowercase
|
||||
// slugs while sessions report the capitalized name (see the case-insensitive
|
||||
// pricing index above). SHORT_NAMES matching is case-sensitive, so map both.
|
||||
|
|
@ -981,28 +987,57 @@ function deriveClaudeShortName(canonical: string): string | undefined {
|
|||
return `${CLAUDE_FAMILY[family]} ${major}${minor ? `.${minor}` : ''}`
|
||||
}
|
||||
|
||||
export function getShortModelName(model: string): string {
|
||||
if (autoModelNames[model]) return autoModelNames[model]
|
||||
const canonical = resolveAlias(getCanonicalName(model))
|
||||
const claude = deriveClaudeShortName(canonical)
|
||||
function lookupShortName(id: string): string | undefined {
|
||||
const claude = deriveClaudeShortName(id)
|
||||
if (claude) return claude
|
||||
for (const [key, name] of SORTED_SHORT_NAMES) {
|
||||
// Match on a version boundary, not a bare prefix: an unlisted future minor
|
||||
// (e.g. gpt-5.6) must NOT collapse into the base "gpt-5" entry — it should
|
||||
// fall through to its raw id rather than show a wrong name/tier.
|
||||
if (canonical === key || canonical.startsWith(key + '-')) return name
|
||||
if (id === key || id.startsWith(key + '-')) return name
|
||||
}
|
||||
// getCanonicalName only strips the leading provider prefix, so a raw
|
||||
// path-style id (e.g. accounts/fireworks/models/glm-5p2) still has slashes
|
||||
// here. Take the last path segment and re-resolve it: the segment may itself
|
||||
// be a known model slug (Fireworks fleet ids), earning a friendly name; a
|
||||
// genuinely unmapped slug resolves to itself, preserving the raw-segment
|
||||
// fallback for everything else.
|
||||
return undefined
|
||||
}
|
||||
|
||||
// Public API stays unary so Array.map/forEach cannot feed index as cycle state.
|
||||
export function getShortModelName(model: string): string {
|
||||
return shortModelName(model, new Set())
|
||||
}
|
||||
|
||||
function shortModelName(model: string, seen: Set<string>): string {
|
||||
if (autoModelNames[model]) return autoModelNames[model]
|
||||
if (seen.has(model)) {
|
||||
const leaf = model.includes('/') ? model.slice(model.lastIndexOf('/') + 1) : model
|
||||
return lookupShortName(leaf) ?? leaf
|
||||
}
|
||||
seen.add(model)
|
||||
|
||||
// User aliases win over built-in display names. A remap of gpt-4o must
|
||||
// show the target, not "GPT-4o".
|
||||
if (Object.hasOwn(userAliases, model)) {
|
||||
return shortModelName(userAliases[model]!, seen)
|
||||
}
|
||||
|
||||
const stripped = getCanonicalName(model)
|
||||
if (stripped !== model) {
|
||||
if (Object.hasOwn(userAliases, stripped)) {
|
||||
return shortModelName(userAliases[stripped]!, seen)
|
||||
}
|
||||
const knownStripped = lookupShortName(stripped)
|
||||
if (knownStripped && !Object.hasOwn(BUILTIN_ALIASES, stripped) && !Object.hasOwn(BUILTIN_ALIASES, stripped.toLowerCase())) {
|
||||
return knownStripped
|
||||
}
|
||||
}
|
||||
|
||||
const canonical = resolveAlias(stripped)
|
||||
const known = lookupShortName(canonical)
|
||||
if (known) return known
|
||||
|
||||
if (canonical.includes('/')) {
|
||||
const segment = canonical.slice(canonical.lastIndexOf('/') + 1)
|
||||
return segment ? getShortModelName(segment) : canonical
|
||||
if (!segment || seen.has(segment) || segment === stripped) {
|
||||
return lookupShortName(segment) ?? segment
|
||||
}
|
||||
return shortModelName(segment, seen)
|
||||
}
|
||||
return canonical
|
||||
return lookupShortName(canonical) ?? canonical
|
||||
}
|
||||
|
||||
// Pricing is process-global state assembled at CLI startup from the cached
|
||||
|
|
|
|||
|
|
@ -310,6 +310,13 @@ describe('user aliases via setModelAliases', () => {
|
|||
expect(getModelCosts('anthropic--claude-4.6-opus')).toEqual(getModelCosts('claude-sonnet-4-5'))
|
||||
})
|
||||
|
||||
it('user alias whose source already has a short name displays the target', () => {
|
||||
setModelAliases({ 'gpt-4o': 'claude-opus-4-6' })
|
||||
expect(getModelCosts('gpt-4o')).toEqual(getModelCosts('claude-opus-4-6'))
|
||||
expect(getShortModelName('gpt-4o')).toBe('Opus 4.6')
|
||||
setModelAliases({})
|
||||
})
|
||||
|
||||
it('resetting aliases restores builtins', () => {
|
||||
setModelAliases({ 'anthropic--claude-4.6-opus': 'claude-sonnet-4-5' })
|
||||
setModelAliases({})
|
||||
|
|
@ -737,6 +744,10 @@ describe('provider pricing suffix variants', () => {
|
|||
describe('observed provider model aliases', () => {
|
||||
const cases: Array<[string, string]> = [
|
||||
['MiMo-V2-Flash', 'xiaomi/mimo-v2-flash'],
|
||||
['mimo-v2.5-pro', 'xiaomi/mimo-v2.5-pro'],
|
||||
['MiMo-v2.5-Pro', 'xiaomi/mimo-v2.5-pro'],
|
||||
['mimo-v2.5', 'xiaomi/mimo-v2.5'],
|
||||
['MiMo-v2.5', 'xiaomi/mimo-v2.5'],
|
||||
['KAT-Coder-Pro-V1', 'kwaipilot/kat-coder-pro'],
|
||||
// Kimi Code wires report bare `k3` in llm.request.model; it must price
|
||||
// through the kimi-k3 table entry, not fall through to $0.
|
||||
|
|
@ -758,6 +769,39 @@ describe('observed provider model aliases', () => {
|
|||
expect(getShortModelName('k3')).toBe('Kimi K3')
|
||||
})
|
||||
|
||||
it('does not recurse on vendor-requalified MiMo aliases', () => {
|
||||
expect(getShortModelName('mimo-v2.5')).toBe('MiMo v2.5')
|
||||
expect(getShortModelName('MiMo-v2.5')).toBe('MiMo v2.5')
|
||||
expect(getShortModelName('cline-pass/mimo-v2.5')).toBe('MiMo v2.5')
|
||||
expect(getShortModelName('cline-pass/mimo-v2.5-pro')).toBe('MiMo v2.5 Pro')
|
||||
})
|
||||
|
||||
// The `mimo-v2-flash -> xiaomi/mimo-v2-flash` alias shipped before this
|
||||
// change and already cycled: strip the namespace, alias it back, take the
|
||||
// leaf, repeat. Every display surface (overview's model table included)
|
||||
// threw RangeError on a real MiMo v2 Flash session. Pin the shipped ids.
|
||||
it('resolves the already-shipped MiMo v2 Flash alias without blowing the stack', () => {
|
||||
for (const id of ['mimo-v2-flash', 'MiMo-V2-Flash', 'cline-pass/mimo-v2-flash', 'mimo/mimo-v2-flash']) {
|
||||
expect(() => getShortModelName(id)).not.toThrow()
|
||||
expect(getShortModelName(id)).toBe('MiMo v2 Flash')
|
||||
expect(getModelCosts(id)).toEqual(getModelCosts('xiaomi/mimo-v2-flash'))
|
||||
}
|
||||
})
|
||||
|
||||
it('names the base MiMo 2.5 row without swallowing the Pro tier', () => {
|
||||
expect(getShortModelName('mimo-v2.5')).toBe('MiMo v2.5')
|
||||
expect(getShortModelName('mimo-v2.5-pro')).toBe('MiMo v2.5 Pro')
|
||||
expect(getModelCosts('mimo-v2.5')).not.toEqual(getModelCosts('mimo-v2.5-pro'))
|
||||
})
|
||||
|
||||
it('stays unary so Array.map cannot feed the index as cycle state', () => {
|
||||
expect(['mimo-v2.5', 'gpt-4o', 'cline-pass/mimo-v2.5-pro'].map(getShortModelName)).toEqual([
|
||||
'MiMo v2.5',
|
||||
'GPT-4o',
|
||||
'MiMo v2.5 Pro',
|
||||
])
|
||||
})
|
||||
|
||||
it('does not map dated Qwen3 Max to a reseller price without provider context', () => {
|
||||
expect(getModelCosts('qwen3-max-2026-01-23')).toBeNull()
|
||||
expect(calculateCost('qwen3-max-2026-01-23', 1_000_000, 1_000_000, 0, 0, 0)).toBe(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue