on main help sign in
fix(opencode): fix qwen3.7-max on opencode (#3040)

* Closes #3027 This model only work on the Anthropic Messages API.

commitb7f4ad6cf61bcca11e052f19c2f2b653aaf818be authorAndrey Nering <andreynering@users.noreply.github.com> dateFri 29 May 2026, 17:14 (5 months ago) parenta4181d6
1 file changed+17−2
internal/agent/coordinator.go+17−2
internal/agent/coordinator.go+17−2
@@ -72,6 +72,11 @@ var copilotResponsesModels = map[string]bool{
7272 "gpt-5-mini": true,
7373}
7474
75+// OpenCode models that user Anthropic Messages API instead of Chat Completions.
76+var opencodeMessagesModels = map[string]bool{
77+ "qwen3.7-max": true,
78+}
79+
7580type Coordinator interface {
7681 // INFO: (kujtim) this is not used yet we will use this when we have multiple agents
7782 // SetMainAgent(string)
@@ -791,7 +796,8 @@ func (c *coordinator) buildOpenaiCompatProvider(baseURL, apiKey string, headers
791796
792797 // Set HTTP client based on provider and debug mode.
793798 var httpClient *http.Client
794− if providerID == string(catwalk.InferenceProviderCopilot) {
799+ switch providerID {
800+ case string(catwalk.InferenceProviderCopilot):
795801 opts = append(
796802 opts,
797803 openaicompat.WithUseResponsesAPI(),
@@ -800,7 +806,8 @@ func (c *coordinator) buildOpenaiCompatProvider(baseURL, apiKey string, headers
800806 }),
801807 )
802808 httpClient = copilot.NewClient(isSubAgent, c.cfg.Config().Options.Debug)
803− } else if c.cfg.Config().Options.Debug {
809+ }
810+ if httpClient == nil && c.cfg.Config().Options.Debug {
804811 httpClient = log.NewHTTPClient()
805812 }
806813 if httpClient != nil {
@@ -929,6 +936,14 @@ func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model con
929936 apiKey, _ := c.cfg.Resolve(providerCfg.APIKey)
930937 baseURL, _ := c.cfg.Resolve(providerCfg.BaseURL)
931938
939+ switch providerCfg.ID {
940+ case string(catwalk.InferenceProviderOpenCodeGo), string(catwalk.InferenceProviderOpenCodeZen):
941+ if opencodeMessagesModels[model.Model] {
942+ baseURL = strings.TrimSuffix(baseURL, "/v1")
943+ return c.buildAnthropicProvider(baseURL, apiKey, headers, providerCfg.ID)
944+ }
945+ }
946+
932947 switch providerCfg.Type {
933948 case openai.Name:
934949 return c.buildOpenaiProvider(baseURL, apiKey, headers)