Skip to content

MessageChatMemoryAdvisor results in an error if prompt is initialized with List<Message> instead of userText #2339

Closed
@rwankar

Description

@rwankar

Bug description
Create a prompt with

Prompt prompt = new Prompt(messages); // list of messages including UserMessage

And set MessageChatMemoryAdvisor as an advisor.

chatClient
  .prompt(prompt)
  .system(systemText)
  .advisors(new MessageChatMemoryAdvisor(chatMemory))

Results in an error that Content cannot be null because MessageChatMemoryAdvisor is looking for userText() which is not present but the prompt already has the UserMessage in list of messages.

Environment
Spring AI 1.0.0-SNAPSHOT
SpringBoot 3.4.2
Java 21

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions