{"record":{"id":"76ad2dbbda2e6c4a","repo":"can1357/oh-my-pi","slug":"error-message","errorCode":null,"errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/inspect-image.ts","lineNumber":244,"sourceCode":"\t\t\t\timageInput = await loadSvgImageInput({\n\t\t\t\t\tpath: imageTarget.path,\n\t\t\t\t\tcwd: this.session.cwd,\n\t\t\t\t\tautoResize,\n\t\t\t\t\tmaxBytes: MAX_IMAGE_INPUT_BYTES,\n\t\t\t\t\texcludeWebP,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\timageInput = await loadImageInput({\n\t\t\t\t\tpath: params.path,\n\t\t\t\t\tcwd: this.session.cwd,\n\t\t\t\t\tautoResize,\n\t\t\t\t\tmaxBytes: MAX_IMAGE_INPUT_BYTES,\n\t\t\t\t\texcludeWebP,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof ImageInputTooLargeError) {\n\t\t\t\tthrow new ToolError(error.message);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!imageInput) {\n\t\t\tthrow new ToolError(\n\t\t\t\tisSvgImage\n\t\t\t\t\t? \"inspect_image ':img' only supports .svg and .svgz files.\"\n\t\t\t\t\t: \"inspect_image only supports PNG, JPEG, GIF, and WEBP files detected by file content.\",\n\t\t\t);\n\t\t}\n\n\t\tconst telemetry = resolveTelemetry(this.session.getTelemetry?.(), this.session.getSessionId?.() ?? undefined);\n\t\tconst timeoutMs = this.session.settings.get(\"inspect_image.timeoutMs\");\n\t\tconst hasTimeout = typeof timeoutMs === \"number\" && Number.isFinite(timeoutMs) && timeoutMs > 0;\n\t\tconst timeoutSignal = hasTimeout ? AbortSignal.timeout(timeoutMs) : undefined;\n\t\tconst effectiveSignal = timeoutSignal\n\t\t\t? signal","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/inspect-image.ts#L226-L262","documentation":"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.","triggerScenarios":"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.","commonSituations":"Inspecting 4K/full-page screenshots; photos from cameras; dense SVG diagrams rasterized at high DPI; autoResize disabled so no downscaling is attempted.","solutions":["Shrink or recompress the image before inspecting (resize dimensions, export as JPEG).","Enable images.autoResize=true so the tool downscales automatically.","Crop the image to the relevant region to cut bytes.","For SVGs, simplify or reduce raster resolution of the ':img' render."],"exampleFix":"// before: raw 12MB screenshot\ninspect_image({ path: \"screen.png\", ... })\n// after\n// $ magick screen.png -resize 1600x screen-small.jpg\ninspect_image({ path: \"screen-small.jpg\", ... })","handlingStrategy":"validation","validationCode":"import { statSync } from \"node:fs\";\nconst size = statSync(imagePath).size;\nif (size > MAX_IMAGE_INPUT_BYTES) {\n  // downscale/compress or crop the image before inspecting\n}","typeGuard":null,"tryCatchPattern":"try {\n  await inspectImageTool.execute(id, params, signal);\n} catch (e) {\n  if (e instanceof ToolError && /too large|bytes/i.test(e.message)) {\n    // resize/re-encode the image and retry once\n  } else throw e;\n}","preventionTips":["Keep images.autoResize enabled so large images are downscaled automatically.","Pre-compress screenshots/photos before pointing the agent at them.","For SVGs, keep them simple or lower the raster resolution used by ':img'."],"tags":["image","size-limit","validation"],"backgroundTag":"payload-too-large","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}