Bug description
When trying to submit a Prompt with UserMessage and AssistantMessage using Spring AI's memory manager, I encountered the following error:
INVALID_ARGUMENT: Unable to submit request because it must include at least one parts field, which describes the prompt input.

The issue arises when calling the model with the Prompt object that includes the system message and the messages from memory. The error suggests that the Prompt does not have the required parts field to describe the input.


Environment
- Spring AI version: 1.0.0-SNAPSHOT - Java version: 21 - Other dependencies: - chatModelName: gemini-1.5-flash-001


Steps to reproduce
1. Add UserMessage and AssistantMessage to the memory manager using:
java memoryManager.addMessage("TODO-CHAT-ID", userMessage); memoryManager.addMessage("TODO-CHAT-ID", assistantMessage); 2. Retrieve the messages from memory and construct the Prompt object:
java List<Message> memoryMessages = memoryManager.getMessages("TODO-CHAT-ID"); List<Message> messages = new ArrayList<>(); messages.add(systemMessage); messages.addAll(memoryMessages); var prompt = new Prompt(messages, chatOptions); 3. Call the model with the constructed Prompt:
java AssistantMessage assistantMessage = chatModel.call(prompt).getResult().getOutput(); memoryManager.addMessage("TODO-CHAT-ID", assistantMessage); 4. The following error occurs:
INVALID_ARGUMENT: Unable to submit request because it must include at least one parts field, which describes the prompt input.


Expected behavior
The model should process the Prompt correctly, using the stored messages from memory and the system message, and return a valid response without triggering the INVALID_ARGUMENT error. The parts field should automatically include the relevant user input and assistant responses.


Minimal Complete Reproducible example

memoryManager.addMessage("TODO-CHAT-ID", userMessage);
memoryManager.addMessage("TODO-CHAT-ID", assistantMessage);

List<Message> memoryMessages = memoryManager.getMessages("TODO-CHAT-ID");
List<Message> messages = new ArrayList<>();
messages.add(systemMessage);
messages.addAll(memoryMessages);

var prompt = new Prompt(messages, chatOptions);

AssistantMessage assistantMessage = chatModel.call(prompt).getResult().getOutput();
memoryManager.addMessage("TODO-CHAT-ID", assistantMessage);

The error occurs at the line where chatModel.call(prompt) is invoked, with the INVALID_ARGUMENT message indicating the missing parts field in the Prompt.

Comment From: dolukhanov

I believe this PR, which has been merged and will be released in 1.0.0-M3 will fix the issue.