| 1 | package boot |
| 2 | |
| 3 | import ( |
| 4 | "errors" |
| 5 | "reflect" |
| 6 | "testing" |
| 7 | |
| 8 | "reasonix/internal/config" |
| 9 | "reasonix/internal/provider" |
| 10 | ) |
| 11 | |
| 12 | func TestOpenCodeGoDeepSeekReasoningContract(t *testing.T) { |
| 13 | for _, model := range []string{"deepseek-v4-flash", "deepseek-v4-pro", "deepseek-v4-flash-vision-exp"} { |
| 14 | for _, kind := range []string{"openai", "anthropic", "responses"} { |
| 15 | t.Run(kind+"/"+model, func(t *testing.T) { |
| 16 | endpoint := map[string]string{"openai": "chat/completions", "anthropic": "messages", "responses": "responses"}[kind] |
| 17 | e := config.ProviderEntry{Name: "opencode-go", Kind: kind, BaseURL: "https://opencode.ai/zen/go/v1", RequestURL: "https://opencode.ai/zen/go/v1/" + endpoint, Model: model, Thinking: "enabled", Effort: "max"} |
| 18 | before := config.ReasoningCapabilityForEntry(&e) |
| 19 | p, err := NewProvider(&e) |
| 20 | if err != nil { |
| 21 | t.Fatal(err) |
| 22 | } |
| 23 | after := p.(provider.ReasoningProvider).ReasoningCapability() |
| 24 | if !reflect.DeepEqual(before.IDs(), after.IDs()) || after.Validate(model, "max") != nil { |
| 25 | t.Fatalf("catalog %v differs from adapter %v", before, after) |
| 26 | } |
| 27 | if !provider.RequiresToolCallReasoning(p) { |
| 28 | t.Fatal("DeepSeek tool reasoning replay is not enabled") |
| 29 | } |
| 30 | }) |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | func TestOpenCodeGoContractDoesNotOverrideCustomEndpoint(t *testing.T) { |
| 36 | e := config.ProviderEntry{Name: "opencode-go", Kind: "anthropic", BaseURL: "https://opencode.ai/zen/go", RequestURL: "https://custom.example/v1/messages", Model: "deepseek-v4-pro", Thinking: "enabled", Effort: "max"} |
| 37 | _, err := NewProvider(&e) |
| 38 | var unsupported *provider.UnsupportedReasoningEffort |
| 39 | if !errors.As(err, &unsupported) { |
| 40 | t.Fatalf("custom endpoint must retain its own binary contract: %v", err) |
| 41 | } |
| 42 | } |
| 43 |