| 1 | package responses |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/provider" |
| 7 | ) |
| 8 | |
| 9 | func TestSharedWindowOutputBudgetCapability(t *testing.T) { |
| 10 | deepseek := &client{vendor: "deepseek", maxOutputTokens: 32 * 1024} |
| 11 | if !deepseek.SharesContextWindow() || deepseek.OutputBudget() != 32*1024 { |
| 12 | t.Fatalf("DeepSeek capability = shared:%v budget:%d", deepseek.SharesContextWindow(), deepseek.OutputBudget()) |
| 13 | } |
| 14 | policy := deepseek.SharedWindowInputPolicy() |
| 15 | if !policy.ReplaysOrdinaryReasoning || !policy.ReplaysResponsesItems { |
| 16 | t.Fatalf("DeepSeek input policy = %+v, want all Responses replay fields", policy) |
| 17 | } |
| 18 | mimo := &client{vendor: "mimo", maxOutputTokens: 128000} |
| 19 | if mimo.SharesContextWindow() { |
| 20 | t.Fatal("MiMo mode must stay unchanged until its shared-window contract is verified") |
| 21 | } |
| 22 | if policy := mimo.SharedWindowInputPolicy(); policy.ReplaysOrdinaryReasoning || policy.ReplaysResponsesItems { |
| 23 | t.Fatalf("MiMo input policy = %+v, want no DeepSeek replay fields", policy) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | func TestOfficialDeepSeekResponsesPolicyOmitsWhenSafe(t *testing.T) { |
| 28 | c := New(Config{Name: "ds", BaseURL: "https://api.deepseek.com", Model: "deepseek-v4-pro"}).(*client) |
| 29 | got := c.ContextBudgetPolicy() |
| 30 | if got.LimitMode != provider.OutputLimitOmitWhenSafe || got.AutoOutputTokens != provider.DeepSeekMaxOutputTokens { |
| 31 | t.Fatalf("responses DeepSeek policy = %+v", got) |
| 32 | } |
| 33 | body, _, _ := c.buildRequestBody(provider.Request{}) |
| 34 | if _, exists := body["max_output_tokens"]; exists { |
| 35 | t.Fatalf("safe official Responses should omit max_output_tokens: %#v", body["max_output_tokens"]) |
| 36 | } |
| 37 | clipped, _, _ := c.buildRequestBody(provider.Request{MaxTokens: 229_502}) |
| 38 | if clipped["max_output_tokens"] != 229_502 { |
| 39 | t.Fatalf("clipped Responses max_output_tokens = %#v", clipped["max_output_tokens"]) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func TestOpenCodeGoResponsesPolicySendsMaxOutputTokens(t *testing.T) { |
| 44 | c := New(Config{Name: "og", BaseURL: "https://opencode.ai/zen/go/v1", Model: "deepseek-v4-flash"}).(*client) |
| 45 | got := c.ContextBudgetPolicy() |
| 46 | if got.LimitMode != provider.OutputLimitAlways || got.MaxOutputTokens != 384_000 { |
| 47 | t.Fatalf("OpenCode Go Responses policy = %+v", got) |
| 48 | } |
| 49 | body, _, _ := c.buildRequestBody(provider.Request{MaxTokens: 384_000}) |
| 50 | if body["max_output_tokens"] != 384_000 { |
| 51 | t.Fatalf("OpenCode Go Responses must send max_output_tokens, got %#v", body["max_output_tokens"]) |
| 52 | } |
| 53 | } |
| 54 |