返回 DeepSeek-Reasonix
opencode_contract_wire_test.go
根目录 / internal / provider / openai / opencode_contract_wire_test.go
1 package openai
2
3 import (
4 "bytes"
5 "encoding/json"
6 "reasonix/internal/provider"
7 "testing"
8 )
9
10 func TestOpenCodeGoDeepSeekWireKeepsReasoningAndStableHistory(t *testing.T) {
11 for _, model := range []string{"deepseek-v4-flash", "deepseek-v4-pro", "deepseek-v4-flash-vision-exp"} {
12 p, err := New(provider.Config{BaseURL: "https://opencode.ai/zen/go/v1", Model: model, Extra: map[string]any{"request_url": "https://opencode.ai/zen/go/v1/chat/completions", "thinking": "enabled", "effort": "max"}})
13 if err != nil {
14 t.Fatal(err)
15 }
16 c := p.(*client)
17 req := provider.Request{Messages: []provider.Message{{Role: provider.RoleUser, Content: "fixture"}, {Role: provider.RoleAssistant, ReasoningContent: "provider-reasoning", ToolCalls: []provider.ToolCall{{ID: "call-1", Name: "read_file", Arguments: "{}"}}}, {Role: provider.RoleTool, ToolCallID: "call-1", Content: "tool-result"}}, MaxTokens: 128}
18 body := c.buildRequest(req)
19 first, _ := json.Marshal(body)
20 second, _ := json.Marshal(c.buildRequest(req))
21 if !bytes.Equal(first, second) || !bytes.Contains(first, []byte(`"reasoning_effort":"max"`)) || !bytes.Contains(first, []byte(`"reasoning_content":"provider-reasoning"`)) {
22 t.Fatalf("%s lost effort/replay/cache stability: %s", model, first)
23 }
24 }
25 }
26
26 lines GO