fix(coding-agent): enforce safe auto-resized image limits closes #2055

This commit is contained in:
Mario Zechner
2026-03-22 21:48:34 +01:00
parent f1fe49a641
commit a78882d8b8
6 changed files with 161 additions and 139 deletions

View File

@@ -160,13 +160,22 @@ export function createReadToolDefinition(
if (autoResizeImages) {
// Resize image if needed before sending it back to the model.
const resized = await resizeImage({ type: "image", data: base64, mimeType });
const dimensionNote = formatDimensionNote(resized);
let textNote = `Read image file [${resized.mimeType}]`;
if (dimensionNote) textNote += `\n${dimensionNote}`;
content = [
{ type: "text", text: textNote },
{ type: "image", data: resized.data, mimeType: resized.mimeType },
];
if (!resized) {
content = [
{
type: "text",
text: `Read image file [${mimeType}]\n[Image omitted: could not be resized below the inline image size limit.]`,
},
];
} else {
const dimensionNote = formatDimensionNote(resized);
let textNote = `Read image file [${resized.mimeType}]`;
if (dimensionNote) textNote += `\n${dimensionNote}`;
content = [
{ type: "text", text: textNote },
{ type: "image", data: resized.data, mimeType: resized.mimeType },
];
}
} else {
content = [
{ type: "text", text: `Read image file [${mimeType}]` },