| 1 | package config |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | // A per-provider effort on the canonical member must not make the DeepSeek |
| 10 | // family non-canonicalizable, or the stored level is unreachable (#8337). |
| 11 | func TestDeepSeekEffortDoesNotBreakFamilyCanonicalization(t *testing.T) { |
| 12 | body := `config_version = 5 |
| 13 | default_model = "deepseek/deepseek-v4-flash" |
| 14 | |
| 15 | [[providers]] |
| 16 | name = "deepseek" |
| 17 | kind = "anthropic" |
| 18 | base_url = "https://api.deepseek.com/anthropic" |
| 19 | models = ["deepseek-v4-flash", "deepseek-v4-pro"] |
| 20 | default = "deepseek-v4-flash" |
| 21 | api_key_env = "DEEPSEEK_API_KEY" |
| 22 | effort = "max" |
| 23 | |
| 24 | [[providers]] |
| 25 | name = "deepseek-flash" |
| 26 | kind = "anthropic" |
| 27 | base_url = "https://api.deepseek.com/anthropic" |
| 28 | api_key_env = "DEEPSEEK_API_KEY" |
| 29 | ` |
| 30 | path := filepath.Join(t.TempDir(), "reasonix.toml") |
| 31 | if err := os.WriteFile(path, []byte(body), 0o644); err != nil { |
| 32 | t.Fatal(err) |
| 33 | } |
| 34 | c := LoadForEdit(path) |
| 35 | if !canCanonicalizeLegacyDeepSeekProviders(c) { |
| 36 | t.Fatal("a per-provider effort selection on the canonical member must not make the DeepSeek family non-canonicalizable") |
| 37 | } |
| 38 | p, ok := c.Provider("deepseek") |
| 39 | if !ok { |
| 40 | t.Fatal("canonical deepseek provider missing") |
| 41 | } |
| 42 | if got := p.Effort; got != "max" { |
| 43 | t.Fatalf("stored effort = %q, want max", got) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | func TestDeepSeekLegacyMembersWithDifferentEffortsStaySeparate(t *testing.T) { |
| 48 | body := `config_version = 5 |
| 49 | default_model = "deepseek-pro/deepseek-v4-pro" |
| 50 | |
| 51 | [[providers]] |
| 52 | name = "deepseek-flash" |
| 53 | kind = "anthropic" |
| 54 | base_url = "https://api.deepseek.com/anthropic" |
| 55 | model = "deepseek-v4-flash" |
| 56 | api_key_env = "DEEPSEEK_API_KEY" |
| 57 | |
| 58 | [[providers]] |
| 59 | name = "deepseek-pro" |
| 60 | kind = "anthropic" |
| 61 | base_url = "https://api.deepseek.com/anthropic" |
| 62 | model = "deepseek-v4-pro" |
| 63 | api_key_env = "DEEPSEEK_API_KEY" |
| 64 | effort = "max" |
| 65 | ` |
| 66 | path := filepath.Join(t.TempDir(), "reasonix.toml") |
| 67 | if err := os.WriteFile(path, []byte(body), 0o644); err != nil { |
| 68 | t.Fatal(err) |
| 69 | } |
| 70 | c := LoadForEdit(path) |
| 71 | if canCanonicalizeLegacyDeepSeekProviders(c) { |
| 72 | t.Fatal("legacy members with different efforts must not merge: the merge keeps only the first member's effort") |
| 73 | } |
| 74 | p, ok := c.Provider("deepseek-pro") |
| 75 | if !ok { |
| 76 | t.Fatal("legacy deepseek-pro provider missing") |
| 77 | } |
| 78 | if got := p.Effort; got != "max" { |
| 79 | t.Fatalf("deepseek-pro effort = %q, want max", got) |
| 80 | } |
| 81 | } |
| 82 |