From 6e1840323e0e6745ec332ea3bfcc4ce7fb8b2f7a Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Tue, 7 Apr 2026 17:33:43 +0200 Subject: [PATCH] Nicer message When there is only one model, change the error shown Signed-off-by: Djordje Lukic --- pkg/runtime/fallback.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/runtime/fallback.go b/pkg/runtime/fallback.go index b6eb347d6..8d5e8d686 100644 --- a/pkg/runtime/fallback.go +++ b/pkg/runtime/fallback.go @@ -324,13 +324,17 @@ func (r *LocalRuntime) tryModelWithFallback( // If the last error (or any error in the chain) was a context overflow, // wrap it in a ContextOverflowError so the caller can auto-compact. if lastErr != nil { - wrapped := fmt.Errorf("all models failed: %w", lastErr) + prefix := "model failed" + if hasFallbacks { + prefix = "all models failed" + } + wrapped := fmt.Errorf("%s: %w", prefix, lastErr) if modelerrors.IsContextOverflowError(lastErr) { return streamResult{}, nil, modelerrors.NewContextOverflowError(wrapped) } return streamResult{}, nil, wrapped } - return streamResult{}, nil, errors.New("all models failed with unknown error") + return streamResult{}, nil, errors.New("model failed with unknown error") } // retryDecision is the outcome of handleModelError.