Fixed chats that are too large being sent again and again

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
j-erlerandClaude Opus 5 committed 2026-09-20 15:59:19 +02:00
1 parent c95cc5bacc
commit 03f962ebce
2 files changed
+25

No files matched your search

@@ -729,6 +729,30 @@ public abstract class BaseProvider : IProvider, ISecretId
break;
}
//
// Some providers answer an oversized request with 413 instead of describing the
// problem in a 400 body. Handled here rather than below, because this is the one
// failure in this loop which cannot get better by being sent again: without its own
// branch it falls through to the retry delays, which resend the very same oversized
// request for several minutes before the user learns anything at all.
//
if(nextResponse.StatusCode is HttpStatusCode.RequestEntityTooLarge)
{
//
// The reason phrase of a 413 says no more than "Request Entity Too Large", and a
// proxy which refuses the request before the provider sees it sends no body worth
// reading. So we show what the body carries and fall back to the phrase:
//
var tooLargeMessage = ReadProviderErrorMessage(errorBody);
if (string.IsNullOrWhiteSpace(tooLargeMessage))
tooLargeMessage = nextResponse.ReasonPhrase;
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.CloudOff, string.Format(TB("We tried to communicate with the LLM provider '{0}' (type={1}). The data of the chat, including all file attachments, is probably too large for the selected model and provider. The provider message is: '{2}'"), this.InstanceName, this.Provider, tooLargeMessage)));
this.logger.LogError("Failed request with status code {ResponseStatusCode} (message = '{ResponseReasonPhrase}', error body = '{ErrorBody}').", nextResponse.StatusCode, nextResponse.ReasonPhrase, errorBody);
errorMessage = nextResponse.ReasonPhrase;
break;
}
if(nextResponse.StatusCode is HttpStatusCode.BadRequest)
{
//