docs(21): mark Gemini image-to-image issue as resolved
- Remove Task 1 (part ordering fix) - no longer needed
- Phase now focused on unifying MD5 hashing for deduplication
- 1 task remaining
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix Gemini nano-banana-pro model ignoring image inputs and resolve duplicate image saving across input/generated images.
Resolve duplicate image saving across input/generated images by unifying the hashing approach.
Purpose: Ensure image-to-image generation works correctly with Gemini and that the deduplication system consistently prevents duplicate files in the generations folder.
Output: Working image-to-image generation with Gemini Pro, consistent hashing across all image saving operations.
Purpose: Ensure the deduplication system consistently prevents duplicate files in the generations folder by using the same hashing algorithm everywhere.
Output: Consistent MD5 hashing across all image saving operations.
**Established patterns:** MD5 content hashing for deduplication (Phase 13)
**Issues being addressed:**
1. nano-banana-pro model generates without considering image inputs (image data sent but not used)
1. ~~nano-banana-pro model generates without considering image inputs~~ - RESOLVED (no longer an issue)
2. Input and generated images have duplicate files despite different hashes - need consistent hashing approach
3. Generated images should be prepended with prompt details like generated videos
**Research findings:**
- Gemini SDK docs show that for image editing, the order matters: image should come BEFORE text in the parts array
- Current implementation sends [text, ...images] but should send [...images, text] for image-to-image
**Root cause:**
- imageStorage.ts uses position-based sampling hash while save-generation uses MD5 - these are incompatible
- Same image saved via different code paths gets different hashes
</context>
<tasks>
<tasktype="auto">
<name>Task 1: Fix Gemini image-to-image part ordering</name>
<files>src/app/api/generate/route.ts</files>
<action>
In generateWithGemini(), change the requestParts array construction to place images BEFORE text prompt. The Gemini SDK documentation shows image editing works with [inlineData, text] order, not [text, inlineData].
Current code (around line 59):
```
const requestParts = [
{ text: prompt }, // Text first - WRONG for image-to-image
...imageData.map(...) // Images second
];
```
Change to:
```
const requestParts = [
...imageData.map(...) // Images first - correct for image editing
{ text: prompt }, // Text second
];
```
WHY: Gemini's image generation models treat the first content type as primary input. For text-to-image, text should be first. For image-to-image (editing), images should be first so the model knows it's modifying existing images.
IMPORTANT: Only reorder when images are present. If no images, text should still be the only part.
</action>
<verify>
Build succeeds with `npm run build`. Manual test: Create workflow with ImageInput → GenerateImage (nano-banana-pro) → Output, connect an image, add prompt like "make it blue", run workflow. Output should visually reference the input image.
</verify>
<done>
When images are connected to a Gemini GenerateImage node, the generated output incorporates/transforms the input image based on the prompt.
</done>
</task>
<tasktype="auto">
<name>Task 2: Unify image hashing to MD5 across all save operations</name>
<name>Task 1: Unify image hashing to MD5 across all save operations</name>
<files>src/utils/imageStorage.ts</files>
<action>
Replace the position-based sampling hash in imageStorage.ts with MD5 content hashing (matching save-generation/route.ts pattern).
@ -111,41 +73,19 @@ imageStorage.ts uses MD5 hashing, consistent with save-generation API. Same imag