summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/context/model-variant.test.ts
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-02-10 10:15:09 -0600
committerGitHub <[email protected]>2026-02-10 10:15:09 -0600
commit6f5dfe125aaa82514318ea39d0ae443da37612f6 (patch)
treee2cc44f2603658e77ad98ce87bb1b77cb7105019 /packages/app/src/context/model-variant.test.ts
parent27fa9dc843d002b67113a1a01727aae61563427e (diff)
downloadopencode-6f5dfe125aaa82514318ea39d0ae443da37612f6.tar.gz
opencode-6f5dfe125aaa82514318ea39d0ae443da37612f6.zip
fix(app): use agent configured variant (#12993)
Diffstat (limited to 'packages/app/src/context/model-variant.test.ts')
-rw-r--r--packages/app/src/context/model-variant.test.ts66
1 files changed, 66 insertions, 0 deletions
diff --git a/packages/app/src/context/model-variant.test.ts b/packages/app/src/context/model-variant.test.ts
new file mode 100644
index 000000000..01b149fd2
--- /dev/null
+++ b/packages/app/src/context/model-variant.test.ts
@@ -0,0 +1,66 @@
+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("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")
+ })
+})