From b7f4ad6cf61bcca11e052f19c2f2b653aaf818be Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Fri, 29 May 2026 17:14:33 -0300 Subject: [PATCH] fix(opencode): fix qwen3.7-max on opencode (#3040) * Closes #3027 This model only work on the Anthropic Messages API. --- internal/agent/coordinator.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/agent/coordinator.go b/internal/agent/coordinator.go index d4c05951e6af1e0243ca80df9dba9410c1529936..a26aa111eeb8e45a699a6aab90774f04a1aca4bb 100644 --- a/internal/agent/coordinator.go +++ b/internal/agent/coordinator.go @@ -72,6 +72,11 @@ var copilotResponsesModels = map[string]bool{ "gpt-5-mini": true, } +// OpenCode models that user Anthropic Messages API instead of Chat Completions. +var opencodeMessagesModels = map[string]bool{ + "qwen3.7-max": true, +} + type Coordinator interface { // INFO: (kujtim) this is not used yet we will use this when we have multiple agents // SetMainAgent(string) @@ -791,7 +796,8 @@ func (c *coordinator) buildOpenaiCompatProvider(baseURL, apiKey string, headers // Set HTTP client based on provider and debug mode. var httpClient *http.Client - if providerID == string(catwalk.InferenceProviderCopilot) { + switch providerID { + case string(catwalk.InferenceProviderCopilot): opts = append( opts, openaicompat.WithUseResponsesAPI(), @@ -800,7 +806,8 @@ func (c *coordinator) buildOpenaiCompatProvider(baseURL, apiKey string, headers }), ) httpClient = copilot.NewClient(isSubAgent, c.cfg.Config().Options.Debug) - } else if c.cfg.Config().Options.Debug { + } + if httpClient == nil && c.cfg.Config().Options.Debug { httpClient = log.NewHTTPClient() } if httpClient != nil { @@ -929,6 +936,14 @@ func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model con apiKey, _ := c.cfg.Resolve(providerCfg.APIKey) baseURL, _ := c.cfg.Resolve(providerCfg.BaseURL) + switch providerCfg.ID { + case string(catwalk.InferenceProviderOpenCodeGo), string(catwalk.InferenceProviderOpenCodeZen): + if opencodeMessagesModels[model.Model] { + baseURL = strings.TrimSuffix(baseURL, "/v1") + return c.buildAnthropicProvider(baseURL, apiKey, headers, providerCfg.ID) + } + } + switch providerCfg.Type { case openai.Name: return c.buildOpenaiProvider(baseURL, apiKey, headers)