Files
archie/internal/gateway/turn_failure.go
T
sam fe8afb18d0
deploy / plan (push) Canceled after 0s
deploy / gate (push) Canceled after 0s
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
ci/woodpecker/push/deploy Pipeline was canceled
fix(gateway): a failed chat turn shows plain wording, not the provider's error (#1902)
2026-11-12 23:11:07 +11:00

31 lines
1.3 KiB
Go

package gateway
import (
"context"
"errors"
"github.com/samcharles93/ai-sdk/chat"
)
// turnFailureText is what a chat reader sees when a turn fails. The cause
// carries provider bodies, URLs and wrapping that belong in the log, which
// failTurn writes, not in front of whoever is chatting.
func turnFailureText(err error) string {
switch {
case errors.Is(err, chat.ErrRateLimited):
return "the model provider is refusing requests (rate limit or spending cap). Try again later, or switch model with /model."
case errors.Is(err, chat.ErrAuthFailed):
return "the model provider rejected Archie's credentials. Check the provider key in settings."
case errors.Is(err, chat.ErrProviderUnavailable):
return "the model provider is unavailable. Try again in a moment."
case errors.Is(err, chat.ErrContextLength):
return "this conversation is too long for the model. Start a new chat, or shorten it with /compress."
case errors.Is(err, chat.ErrUnsupportedContent):
return "the model can't read one of the attachments. Remove it, or switch model with /model."
case errors.Is(err, context.DeadlineExceeded):
return "the model took too long to answer. Try again."
default:
return "something went wrong on Archie's side. Try again; the gateway log has the cause."
}
}