Download packages/app/src/context/model-variant.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 2.24 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/context/model-variant.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/context/model-variant.test.ts
-
curl -L -o model-variant.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/context/model-variant.test.ts
2.24 kB
| import { describe, expect, test } from "bun:test" | |
| import { cycleModelVariant, getConfiguredAgentVariant, resolveModelVariant } from "./model-variant" | |
| describe("model variant", () => { | |
| test("resolves configured agent variant when model matches", () => { | |
| const value = getConfiguredAgentVariant({ | |
| agent: { | |
| model: { providerID: "openai", modelID: "gpt-5.2" }, | |
| variant: "xhigh", | |
| }, | |
| model: { | |
| providerID: "openai", | |
| modelID: "gpt-5.2", | |
| variants: { low: {}, high: {}, xhigh: {} }, | |
| }, | |
| }) | |
| expect(value).toBe("xhigh") | |
| }) | |
| test("ignores configured variant when model does not match", () => { | |
| const value = getConfiguredAgentVariant({ | |
| agent: { | |
| model: { providerID: "openai", modelID: "gpt-5.2" }, | |
| variant: "xhigh", | |
| }, | |
| model: { | |
| providerID: "anthropic", | |
| modelID: "claude-sonnet-4", | |
| variants: { low: {}, high: {}, xhigh: {} }, | |
| }, | |
| }) | |
| expect(value).toBeUndefined() | |
| }) | |
| test("prefers selected variant over configured variant", () => { | |
| const value = resolveModelVariant({ | |
| variants: ["low", "high", "xhigh"], | |
| selected: "high", | |
| configured: "xhigh", | |
| }) | |
| expect(value).toBe("high") | |
| }) | |
| test("lets an explicit default override the configured variant", () => { | |
| const value = resolveModelVariant({ | |
| variants: ["low", "high", "xhigh"], | |
| selected: null, | |
| configured: "xhigh", | |
| }) | |
| expect(value).toBeUndefined() | |
| }) | |
| test("cycles from configured variant to next", () => { | |
| const value = cycleModelVariant({ | |
| variants: ["low", "high", "xhigh"], | |
| selected: undefined, | |
| configured: "high", | |
| }) | |
| expect(value).toBe("xhigh") | |
| }) | |
| test("wraps from configured last variant to first", () => { | |
| const value = cycleModelVariant({ | |
| variants: ["low", "high", "xhigh"], | |
| selected: undefined, | |
| configured: "xhigh", | |
| }) | |
| expect(value).toBe("low") | |
| }) | |
| test("cycles from an explicit default to the first variant", () => { | |
| const value = cycleModelVariant({ | |
| variants: ["low", "high", "xhigh"], | |
| selected: null, | |
| configured: "xhigh", | |
| }) | |
| expect(value).toBe("low") | |
| }) | |
| }) | |