Images are not kept in the thread context
Hey everyone, I’m running into an issue with Mastra when using it for image generation. I’m building an agent that generates images through a chat interface, using the Nano Banana image-to-image model. The problem is that image generation only works correctly if the image generation tool is called within the same message where the user uploads the image.
Has anyone faced this before or found a way to make it work across multiple messages (e.g., when the image is uploaded in one message and processed in the next)?
3 Replies
Hey @Lucas Fernandes ! I don't know if I 100% understand what you're asking for, but you can send multiple part within one single message
@Romain I'm already sending messages like that. But for example, one of my tools require more than an image, so even after the user send an image, the chat may ask for more info. But after the user provides more info, when it's the time to use the file sent in the past messages, the LLM hallucinates and uses an random link, instead of the one provided in other messages.
I'm using Gemini 2.5 Flash
I see, I understand now 😉 Have you tried with the pro version of gemini 2.5 just to see if you're still having this issue? I've seen people running into weird issue with tool calls when using flash/lite.