can1357/oh-my-pi · error · ToolError

${error.message}

Error message

${error.message}

What it means

While loading the image (file, SVG, or attachment), an ImageInputTooLargeError was raised because the image exceeds MAX_IMAGE_INPUT_BYTES. The tool converts it to a ToolError carrying the original message (which includes size limits and the actual size). This is a pre-flight guard so oversized images never reach the provider.

Source

Thrown at packages/coding-agent/src/tools/inspect-image.ts:244

				imageInput = await loadSvgImageInput({
					path: imageTarget.path,
					cwd: this.session.cwd,
					autoResize,
					maxBytes: MAX_IMAGE_INPUT_BYTES,
					excludeWebP,
				});
			} else {
				imageInput = await loadImageInput({
					path: params.path,
					cwd: this.session.cwd,
					autoResize,
					maxBytes: MAX_IMAGE_INPUT_BYTES,
					excludeWebP,
				});
			}
		} catch (error) {
			if (error instanceof ImageInputTooLargeError) {
				throw new ToolError(error.message);
			}
			throw error;
		}

		if (!imageInput) {
			throw new ToolError(
				isSvgImage
					? "inspect_image ':img' only supports .svg and .svgz files."
					: "inspect_image only supports PNG, JPEG, GIF, and WEBP files detected by file content.",
			);
		}

		const telemetry = resolveTelemetry(this.session.getTelemetry?.(), this.session.getSessionId?.() ?? undefined);
		const timeoutMs = this.session.settings.get("inspect_image.timeoutMs");
		const hasTimeout = typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0;
		const timeoutSignal = hasTimeout ? AbortSignal.timeout(timeoutMs) : undefined;
		const effectiveSignal = timeoutSignal
			? signal

View on GitHub (pinned to 9690622007)

Solutions

  1. Shrink or recompress the image before inspecting (resize dimensions, export as JPEG).
  2. Enable images.autoResize=true so the tool downscales automatically.
  3. Crop the image to the relevant region to cut bytes.
  4. For SVGs, simplify or reduce raster resolution of the ':img' render.

Example fix

// before: raw 12MB screenshot
inspect_image({ path: "screen.png", ... })
// after
// $ magick screen.png -resize 1600x screen-small.jpg
inspect_image({ path: "screen-small.jpg", ... })
Defensive patterns

Strategy: validation

Validate before calling

import { statSync } from "node:fs";
const size = statSync(imagePath).size;
if (size > MAX_IMAGE_INPUT_BYTES) {
  // downscale/compress or crop the image before inspecting
}

Try / catch

try {
  await inspectImageTool.execute(id, params, signal);
} catch (e) {
  if (e instanceof ToolError && /too large|bytes/i.test(e.message)) {
    // resize/re-encode the image and retry once
  } else throw e;
}

Prevention

When it happens

Trigger: Calling inspect_image with an image file/attachment whose encoded size exceeds MAX_IMAGE_INPUT_BYTES even after optional auto-resize (images.autoResize setting) — e.g. huge screenshots, high-res photos, or large SVGs (with :img) that rasterize past the cap.

Common situations: Inspecting 4K/full-page screenshots; photos from cameras; dense SVG diagrams rasterized at high DPI; autoResize disabled so no downscaling is attempted.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/76ad2dbbda2e6c4a. Report an issue: GitHub.