Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/runtime/fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading