Nothing Gets Lost.
If you walk away while a bot is generating media, it queues the result and delivers it the moment you return. No lost images, no repeated requests.
The Problem
User walks up to a bot and asks it to generate an image.
The bot calls a tool (e.g. ComfyUI) — generation takes 10-30 seconds.
User walks away to another part of the room. The tool finishes. The image is ready — but there's nobody to send it to.
Without pending media: the image is lost. The user comes back and has to ask again.
The Fix
Pre-queue — URLs from tool results are queued to pendingMedia immediately after the tool finishes, before the AI generates its response.
Re-entry detection — when the user walks back to the bot, flushPendingMedia delivers all queued media.
Deduplication — originalUrl tracking prevents the bot from re-sending the same image if the user already received it.
Greeting context — the bot's greeting on re-entry notes that media was delivered while away, so the AI doesn't try to re-generate it.
Delivery Flow
1. Tool Runs
Bot calls MCP tool, gets result with media URLs
2. Pre-Queue
URLs saved to pendingMedia immediately
3. User Returns
Re-entry triggers flushPendingMedia
4. Delivered
Media sent to chat, greeting notes delivery
Reliable by design
Walk away, come back — your media is waiting.