fix: honor auto fallback when model selection is unsupported

This commit is contained in:
ayattara
2026-09-09 04:05:25 +00:00
parent 55e23b4478
commit fdfbffc9ad
2 changed files with 17 additions and 0 deletions
@@ -140,6 +140,13 @@ func applyStartModelPolicy(
decision.SetModelCalled = true
if err := applier.SetModel(ctx, policy.Model); err != nil {
if sessionmodel.IsMethodNotFound(err) {
if policy.AutoFallback {
log.Debug("agent does not support model selection, continuing on provider default",
zap.String("model", policy.Model), zap.Error(err))
decision = providerDefaultDecision(state, policy, ModelSelectionReasonSelectionUnsupported)
decision.SetModelCalled = true
return decision, nil
}
unsupported, unavailableErr := unavailableStartModel(state, policy, ModelSelectionReasonSelectionUnsupported)
unsupported.SetModelCalled = true
return unsupported, unavailableErr
@@ -79,6 +79,16 @@ func TestApplyStartModelPolicyExecutorAuthority(t *testing.T) {
wantCalls: []string{"requested"},
wantErr: `requested model "requested" is unavailable (reason: selection_unsupported)`,
},
{
name: "auto fallback allows unsupported model selection",
state: modelState("requested"),
policy: StartModelPolicy{Model: "requested", AutoFallback: true},
applierErrors: []error{methodNotFoundErr()},
wantCalls: []string{"requested"},
wantOutcome: ModelSelectionOutcomeProviderDefault,
wantReason: ModelSelectionReasonSelectionUnsupported,
wantWarning: true,
},
{
name: "auto fallback allows absent requested model",
state: modelState("executor-default"),