| 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | |
| 3 | import { ProviderInstanceId, type ModelSelection } from "@t3tools/contracts"; |
| 4 | |
| 5 | import { compileClaudeModelSelection } from "./claudeModelOptions.ts"; |
| 6 | |
| 7 | const selection = ( |
| 8 | model: string, |
| 9 | options: NonNullable<ModelSelection["options"]>, |
| 10 | ): ModelSelection => ({ |
| 11 | instanceId: ProviderInstanceId.make("claude_test"), |
| 12 | model, |
| 13 | options, |
| 14 | }); |
| 15 | |
| 16 | describe("compileClaudeModelSelection", () => { |
| 17 | it("compiles context, effort, and settings together", () => { |
| 18 | expect( |
| 19 | compileClaudeModelSelection( |
| 20 | selection("claude-opus-4-6", [ |
| 21 | { id: "contextWindow", value: "1m" }, |
| 22 | { id: "effort", value: "max" }, |
| 23 | { id: "fastMode", value: true }, |
| 24 | ]), |
| 25 | ), |
| 26 | ).toMatchObject({ |
| 27 | apiModelId: "claude-opus-4-6[1m]", |
| 28 | effort: "max", |
| 29 | settings: { fastMode: true }, |
| 30 | }); |
| 31 | }); |
| 32 | |
| 33 | it("compiles fast mode only for models that expose it", () => { |
| 34 | expect( |
| 35 | compileClaudeModelSelection(selection("claude-opus-4-6", [{ id: "fastMode", value: true }])) |
| 36 | .settings, |
| 37 | ).toEqual({ fastMode: true }); |
| 38 | expect( |
| 39 | compileClaudeModelSelection(selection("claude-opus-4-6", [{ id: "fastMode", value: false }])) |
| 40 | .settings, |
| 41 | ).toEqual({ fastMode: false }); |
| 42 | }); |
| 43 | |
| 44 | it("uses the model default SDK effort alongside prompt-injected effort", () => { |
| 45 | expect( |
| 46 | compileClaudeModelSelection( |
| 47 | selection("claude-sonnet-4-6", [{ id: "effort", value: "ultrathink" }]), |
| 48 | ), |
| 49 | ).toMatchObject({ effort: "high", promptEffort: "ultrathink" }); |
| 50 | }); |
| 51 | |
| 52 | it("compiles the thinking toggle for models that expose it", () => { |
| 53 | expect( |
| 54 | compileClaudeModelSelection(selection("claude-haiku-4-5", [{ id: "thinking", value: false }])) |
| 55 | .settings, |
| 56 | ).toEqual({ alwaysThinkingEnabled: false }); |
| 57 | }); |
| 58 | }); |