{"record":{"id":"b63ff15262e4b2ce","repo":"can1357/oh-my-pi","slug":"no-image-attachments-are-available-in-this-turn-p","errorCode":null,"errorMessage":"No image attachments are available in this turn. path=\"${options.path}\" must be a readable file path or attachment URI.","messagePattern":"No image attachments are available in this turn\\. path=\"(.+?)\" must be a readable file path or attachment URI\\.","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/inspect-image.ts","lineNumber":79,"sourceCode":"}\n\nfunction formatAvailableImageAttachments(attachments: readonly { label: string; uri: string }[]): string {\n\tif (attachments.length === 0) return \"none\";\n\treturn attachments.map(attachment => `${attachment.label} -> ${attachment.uri}`).join(\", \");\n}\n\nasync function loadAttachmentReferenceInput(options: {\n\tpath: string;\n\treference: ImageAttachmentReference;\n\tattachments: readonly { label: string; uri: string; image: ImageContent }[];\n\tautoResize: boolean;\n\texcludeWebP: boolean | undefined;\n}): Promise<LoadedImageInput | null> {\n\tconst attachment = options.attachments[options.reference.index - 1];\n\tif (!attachment) {\n\t\tconst available = formatAvailableImageAttachments(options.attachments);\n\t\tif (options.attachments.length === 0) {\n\t\t\tthrow new ToolError(\n\t\t\t\t`No image attachments are available in this turn. path=\"${options.path}\" must be a readable file path or attachment URI.`,\n\t\t\t);\n\t\t}\n\t\tthrow new ToolError(\n\t\t\t`Could not resolve image attachment '${options.path}'. Available image attachments: ${available}. Pass an attachment URI or a readable filesystem path.`,\n\t\t);\n\t}\n\treturn loadImageAttachmentInput({\n\t\timage: attachment.image,\n\t\tlabel: attachment.label,\n\t\turi: attachment.uri,\n\t\tautoResize: options.autoResize,\n\t\tmaxBytes: MAX_IMAGE_INPUT_BYTES,\n\t\texcludeWebP: options.excludeWebP,\n\t});\n}\n\nexport interface InspectImageToolDetails {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/inspect-image.ts#L61-L97","documentation":"The inspect-image tool's loadAttachmentReferenceInput resolves a path-like reference to an image attachment from the current turn. When the reference index points past the attachment list and the list is entirely empty, there is nothing to resolve, so a ToolError is thrown telling the caller the path must be a real file path or attachment URI instead.","triggerScenarios":"Calling inspect-image with path referencing an attachment (e.g. attachment index syntax) while options.attachments is empty for the current turn, at inspect-image.ts:79. Raised from execute via loadAttachmentReferenceInput.","commonSituations":"Agent tries to inspect an image from a previous conversation turn (attachments are per-turn); referencing an attachment before any image tool produced output this turn; stale attachment index after context compaction.","solutions":["Pass a real filesystem path to the image file instead of an attachment reference.","Re-generate or re-load the image in the current turn so it becomes an attachment, then reference it.","Check available image attachments this turn before referencing (the sibling error 2519 lists them when non-empty).","If the image came from an earlier turn, find its saved output path on disk and use that."],"exampleFix":"// before\ninspect_image({ path: \"attachment://1\" }) // no attachments this turn\n// after\ninspect_image({ path: \"/tmp/omp/output/chart.png\" })","handlingStrategy":"validation","validationCode":"const isAttachmentUri = (p: string) => p.startsWith('attachment://');\nif (isAttachmentUri(params.path) && currentTurnAttachments.length === 0) {\n  throw new Error('No attachments this turn; pass a filesystem path to the image instead');\n}\nif (!isAttachmentUri(params.path) && !fs.existsSync(params.path)) {\n  throw new Error(`Path not found: ${params.path}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await inspectImage({ path });\n} catch (err) {\n  if (err instanceof ToolError && err.message.includes('No image attachments')) {\n    // fall back to filesystem path or regenerate the image this turn\n  } else throw err;\n}","preventionTips":["Never carry attachment URIs across turns; save outputs to disk and use paths","Check current-turn attachment list before referencing one","Prefer absolute filesystem paths for images not produced this turn"],"tags":["validation","attachments","image-inspection","path-resolution"],"backgroundTag":"resource-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}