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
@@ -549,6 +549,43 @@ func TestImageFallback_NoCandidates(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageFallbackCandidate_PreservesConfigIdentity(t *testing.T) {
|
||||
fc := NewFallbackChain(NewCooldownTracker(), nil)
|
||||
candidates := []FallbackCandidate{
|
||||
{Provider: "openai", Model: "vision", IdentityKey: "model_name:first", ConfigKey: "config:first"},
|
||||
{Provider: "openai", Model: "vision", IdentityKey: "model_name:second", ConfigKey: "config:second"},
|
||||
}
|
||||
var seen []string
|
||||
result, err := fc.ExecuteImageCandidate(
|
||||
context.Background(),
|
||||
candidates,
|
||||
func(_ context.Context, candidate FallbackCandidate) (*LLMResponse, error) {
|
||||
seen = append(seen, candidate.ConfigKey)
|
||||
if candidate.ConfigKey == "config:first" {
|
||||
return nil, errors.New("retry")
|
||||
}
|
||||
return &LLMResponse{Content: "ok"}, nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("ExecuteImageCandidate() error = %v", err)
|
||||
}
|
||||
if len(seen) != 2 || seen[0] != "config:first" || seen[1] != "config:second" {
|
||||
t.Fatalf("candidate identities = %v, want [config:first config:second]", seen)
|
||||
}
|
||||
if result.IdentityKey != candidates[1].StableKey() {
|
||||
t.Fatalf("IdentityKey = %q, want %q", result.IdentityKey, candidates[1].StableKey())
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackCandidateStableKeyIncludesConfigIdentity(t *testing.T) {
|
||||
first := FallbackCandidate{IdentityKey: "model_name:shared", ConfigKey: "config:first"}
|
||||
second := FallbackCandidate{IdentityKey: "model_name:shared", ConfigKey: "config:second"}
|
||||
if first.StableKey() == second.StableKey() {
|
||||
t.Fatalf("StableKey() = %q for distinct configurations", first.StableKey())
|
||||
}
|
||||
}
|
||||
|
||||
// --- ResolveCandidates Tests ---
|
||||
|
||||
func TestResolveCandidates_Simple(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user