From 007b2ae8bd255f2addd07547c3a5ae6bc2ce6172 Mon Sep 17 00:00:00 2001 From: Sutra Hsing Date: Sun, 7 Jun 2026 15:34:59 +0800 Subject: [PATCH] fix(config): use canonical Anthropic default model ID --- pkg/config/config_test.go | 23 +++++++++++++++++++++++ pkg/config/defaults.go | 2 +- pkg/providers/factory_provider_test.go | 15 +++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 213090a15..ea90fafe4 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -907,6 +907,29 @@ func TestDefaultConfig_WorkspacePath(t *testing.T) { } } +// TestDefaultConfig_AnthropicModelsUseClaudeAPIIDs verifies that first-party +// Anthropic defaults use Claude API model IDs, not dotted display names or +// Bedrock-style provider prefixes. See: +// https://platform.claude.com/docs/en/about-claude/models/model-ids-and-versions +func TestDefaultConfig_AnthropicModelsUseClaudeAPIIDs(t *testing.T) { + cfg := DefaultConfig() + + checked := 0 + for _, model := range cfg.ModelList { + if model.Provider != "anthropic" { + continue + } + checked++ + if strings.Contains(model.Model, ".") { + t.Fatalf("Anthropic default model %q uses dotted ID %q", model.ModelName, model.Model) + } + } + + if checked == 0 { + t.Fatal("DefaultConfig() missing Anthropic models") + } +} + // TestDefaultConfig_MaxTokens verifies max tokens has default value func TestDefaultConfig_MaxTokens(t *testing.T) { cfg := DefaultConfig() diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index d7bd16875..d06463719 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -88,7 +88,7 @@ func DefaultConfig() *Config { { ModelName: "claude-sonnet-4.6", Provider: "anthropic", - Model: "claude-sonnet-4.6", + Model: "claude-sonnet-4-6", APIBase: "https://api.anthropic.com/v1", }, diff --git a/pkg/providers/factory_provider_test.go b/pkg/providers/factory_provider_test.go index c4ef8a4aa..e772d0a11 100644 --- a/pkg/providers/factory_provider_test.go +++ b/pkg/providers/factory_provider_test.go @@ -1081,6 +1081,21 @@ func TestModelProviderOptions(t *testing.T) { } else if option.DefaultAPIBase != "https://api.anthropic.com/v1" { t.Fatalf("anthropic default_api_base = %q, want %q", option.DefaultAPIBase, "https://api.anthropic.com/v1") } + // First-party Claude API model IDs use hyphenated formats such as + // claude-{name}-{major}-{minor} or claude-{name}-{major}-{minor}-{YYYYMMDD}; + // dotted provider prefixes are for platform-specific IDs such as Bedrock. + // https://platform.claude.com/docs/en/about-claude/models/model-ids-and-versions + for _, provider := range []string{"anthropic", "anthropic-messages"} { + option, ok := seen[provider] + if !ok { + t.Fatalf("%s option missing", provider) + } + for _, model := range option.CommonModels { + if strings.Contains(model, ".") { + t.Fatalf("%s common_model %q uses dotted ID", provider, model) + } + } + } if _, ok := seen["azure"]; !ok { t.Fatal("azure option missing") }