diff --git a/ui/litellm-dashboard/src/components/edit_auto_router/auto_router_tier_model_replacement.test.ts b/ui/litellm-dashboard/src/components/edit_auto_router/auto_router_tier_model_replacement.test.ts new file mode 100644 index 00000000000..68df4f6b11b --- /dev/null +++ b/ui/litellm-dashboard/src/components/edit_auto_router/auto_router_tier_model_replacement.test.ts @@ -0,0 +1,42 @@ +import { describe, expect, it } from "vitest"; + +import { applyTierSetAction } from "../add_model/tier_set_actions"; +import { buildUpdatedComplexityRouterConfig, hydrateComplexityRouterConfig } from "./edit_auto_router_modal"; + +describe("auto-router tier model replacement", () => { + it("writes the replacement model and drops params tied to the removed model", () => { + const stored = { + tiers: { + SIMPLE: ["gemma4:12b-it-qat"], + MEDIUM: [], + COMPLEX: [], + REASONING: [], + }, + tier_model_configs: { + SIMPLE: [ + { + model_name: "gemma4:12b-it-qat", + litellm_params: { reasoning_effort: "medium" }, + }, + ], + }, + classifier_type: "heuristic" as const, + }; + + const hydrated = hydrateComplexityRouterConfig(stored, "gemma4:12b-it-qat"); + const changed = applyTierSetAction(hydrated, [], { + kind: "models", + id: "SIMPLE", + models: ["gemma4-12b-it-optiq-4bit"], + }).value; + const saved = buildUpdatedComplexityRouterConfig(stored, changed); + + expect(saved.tiers).toEqual({ + SIMPLE: ["gemma4-12b-it-optiq-4bit"], + MEDIUM: [], + COMPLEX: [], + REASONING: [], + }); + expect(saved).not.toHaveProperty("tier_model_configs"); + }); +});