on main help sign in
fix(opencode): fix qwen3.7-max on opencode (#3040)
b7f4ad6Andrey Nering
internal/agent/coordinator.go+17−2
@@ -72,6 +72,11 @@ var copilotResponsesModels = map[string]bool{
72 "gpt-5-mini": true,
72 "gpt-5-mini": true,
73}
73}
74
74
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+
75type Coordinator interface {
80type Coordinator interface {
76 // INFO: (kujtim) this is not used yet we will use this when we have multiple agents
81 // INFO: (kujtim) this is not used yet we will use this when we have multiple agents
77 // SetMainAgent(string)
82 // SetMainAgent(string)
@@ -791,7 +796,8 @@ func (c *coordinator) buildOpenaiCompatProvider(baseURL, apiKey string, headers
791
796
792 // Set HTTP client based on provider and debug mode.
797 // Set HTTP client based on provider and debug mode.
793 var httpClient *http.Client
798 var httpClient *http.Client
799+ switch providerID {
794− if providerID == string(catwalk.InferenceProviderCopilot) {
800+ case string(catwalk.InferenceProviderCopilot):
795 opts = append(
801 opts = append(
796 opts,
802 opts,
797 openaicompat.WithUseResponsesAPI(),
803 openaicompat.WithUseResponsesAPI(),
@@ -800,7 +806,8 @@ func (c *coordinator) buildOpenaiCompatProvider(baseURL, apiKey string, headers
800 }),
806 }),
801 )
807 )
802 httpClient = copilot.NewClient(isSubAgent, c.cfg.Config().Options.Debug)
808 httpClient = copilot.NewClient(isSubAgent, c.cfg.Config().Options.Debug)
809+ }
803− } else if c.cfg.Config().Options.Debug {
810+ if httpClient == nil && c.cfg.Config().Options.Debug {
804 httpClient = log.NewHTTPClient()
811 httpClient = log.NewHTTPClient()
805 }
812 }
806 if httpClient != nil {
813 if httpClient != nil {
@@ -929,6 +936,14 @@ func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model con
929 apiKey, _ := c.cfg.Resolve(providerCfg.APIKey)
936 apiKey, _ := c.cfg.Resolve(providerCfg.APIKey)
930 baseURL, _ := c.cfg.Resolve(providerCfg.BaseURL)
937 baseURL, _ := c.cfg.Resolve(providerCfg.BaseURL)
931
938
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+
932 switch providerCfg.Type {
947 switch providerCfg.Type {
933 case openai.Name:
948 case openai.Name:
934 return c.buildOpenaiProvider(baseURL, apiKey, headers)
949 return c.buildOpenaiProvider(baseURL, apiKey, headers)