fix: avoid global image size regression

This commit is contained in:
Shadow
2026-01-27 15:59:11 -06:00
committed by Shadow
parent b59ea0e3f3
commit 20c0d1f2c5
4 changed files with 26 additions and 6 deletions

View File

@@ -34,7 +34,7 @@ import {
isContextOverflowError,
isFailoverAssistantError,
isFailoverErrorMessage,
isImageSizeError,
parseImageSizeError,
parseImageDimensionError,
isRateLimitAssistantError,
isTimeoutErrorMessage,
@@ -442,12 +442,17 @@ export async function runEmbeddedPiAgent(
};
}
// Handle image size errors with a user-friendly message (no retry needed)
if (isImageSizeError(errorText)) {
const imageSizeError = parseImageSizeError(errorText);
if (imageSizeError) {
const maxMb = imageSizeError.maxMb;
const maxMbLabel =
typeof maxMb === "number" && Number.isFinite(maxMb) ? `${maxMb}` : null;
const maxBytesHint = maxMbLabel ? ` (max ${maxMbLabel}MB)` : "";
return {
payloads: [
{
text:
"Image too large for the model (max 5MB). " +
`Image too large for the model${maxBytesHint}. ` +
"Please compress or resize the image and try again.",
isError: true,
},