| 1 | package openai |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/provider" |
| 7 | ) |
| 8 | |
| 9 | func TestExplicitKimiK3GatewayRequestContract(t *testing.T) { |
| 10 | p, err := New(provider.Config{ |
| 11 | Name: "custom-kimi-gateway", BaseURL: "https://gateway.example.com/v1", Model: "kimi-k3", |
| 12 | Extra: map[string]any{"effort": "high", "reasoning_protocol": "kimi-k3"}, |
| 13 | }) |
| 14 | if err != nil { |
| 15 | t.Fatalf("New explicit Kimi K3 gateway: %v", err) |
| 16 | } |
| 17 | if !provider.RequiresReasoningRoundTrip(p) { |
| 18 | t.Fatal("explicit Kimi K3 protocol must retain reasoning for complete assistant-message replay") |
| 19 | } |
| 20 | req := p.(*client).buildRequest(provider.Request{ |
| 21 | Temperature: provider.TemperaturePtr(0.2), MaxTokens: 4096, |
| 22 | Messages: []provider.Message{ |
| 23 | {Role: provider.RoleUser, Content: "question"}, |
| 24 | {Role: provider.RoleAssistant, Content: "answer", ReasoningContent: "gateway reasoning"}, |
| 25 | }, |
| 26 | }) |
| 27 | if req.ReasoningEffort != "high" || req.Temperature != nil || req.MaxTokens != 0 || req.MaxCompletionTokens != 4096 { |
| 28 | t.Fatalf("explicit Kimi K3 request shape = %+v", req) |
| 29 | } |
| 30 | if got := req.Messages[1].ReasoningContent; got == nil || *got != "gateway reasoning" { |
| 31 | t.Fatalf("explicit Kimi K3 reasoning_content = %v, want gateway reasoning", got) |
| 32 | } |
| 33 | if _, err := New(provider.Config{ |
| 34 | Name: "custom-kimi-gateway", BaseURL: "https://gateway.example.com/v1", Model: "kimi-k3", |
| 35 | Extra: map[string]any{"effort": "medium", "reasoning_protocol": "kimi-k3"}, |
| 36 | }); err == nil { |
| 37 | t.Fatal("explicit Kimi K3 protocol should reject unsupported medium effort") |
| 38 | } |
| 39 | auto, err := New(provider.Config{ |
| 40 | Name: "custom-kimi-gateway", BaseURL: "https://gateway.example.com/v1", Model: "kimi-k3", |
| 41 | Extra: map[string]any{ |
| 42 | "reasoning_protocol": "kimi-k3", |
| 43 | "supported_efforts": []string{"medium", "ultra"}, |
| 44 | }, |
| 45 | }) |
| 46 | if err != nil { |
| 47 | t.Fatalf("New Kimi K3 with dormant custom efforts: %v", err) |
| 48 | } |
| 49 | if got := auto.(*client).buildRequest(provider.Request{}).ReasoningEffort; got != "max" { |
| 50 | t.Fatalf("Kimi K3 protocol default effort = %q, want max", got) |
| 51 | } |
| 52 | } |
| 53 |