feat(models): add configurable default fallback chain (#3200)
* feat(models): add configurable default fallback chain * fix(lint): resolve linter issues * fix(models): keep default fallback chain valid * fix(models): normalize default chain on model writes * fix(models): harden fallback chain consistency * fix(models): preserve raw model provider injection * fix(agent): preserve provider-prefixed model configs * fix(agent): preserve injected provider contracts * fix(agent): preserve fallback providers after model switch * fix(build): update Go to 1.25.13
This commit is contained in:
39 files changed
+5376
-436
No files matched your search
@@ -89,7 +89,8 @@ func hasModelConfiguration(m *config.ModelConfig) bool {
|
||||
authMethod := strings.ToLower(strings.TrimSpace(m.AuthMethod))
|
||||
apiKey := strings.TrimSpace(m.APIKey())
|
||||
|
||||
if authMethod == "oauth" || authMethod == "token" {
|
||||
usesStoredAuth := authMethod == "oauth" || authMethod == "token"
|
||||
if usesStoredAuth {
|
||||
if configured, checked := hasStoredOAuthCredential(m); checked {
|
||||
return configured
|
||||
}
|
||||
@@ -109,7 +110,23 @@ func hasModelConfiguration(m *config.ModelConfig) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
return apiKey != ""
|
||||
if apiKey != "" {
|
||||
return true
|
||||
}
|
||||
if usesStoredAuth {
|
||||
return false
|
||||
}
|
||||
apiBase := strings.TrimSpace(m.APIBase)
|
||||
if apiBase == "" {
|
||||
return false
|
||||
}
|
||||
switch providers.NormalizeProvider(protocol) {
|
||||
case "anthropic", "anthropic-messages", "alibaba-coding-anthropic":
|
||||
return false
|
||||
}
|
||||
defaultBase := providers.DefaultAPIBaseForProtocol(protocol)
|
||||
return defaultBase == "" ||
|
||||
normalizeAPIBaseForCompare(apiBase) != normalizeAPIBaseForCompare(defaultBase)
|
||||
}
|
||||
|
||||
func hasStoredOAuthCredential(m *config.ModelConfig) (bool, bool) {
|
||||
|
||||
Reference in new issue
Block a user