GH-4170 Fixed the issue where SystemMessage was not being saved to the chat memory#4189
GH-4170 Fixed the issue where SystemMessage was not being saved to the chat memory#4189sunyuhan1998 wants to merge 1 commit into
SystemMessage was not being saved to the chat memory#4189Conversation
… not being saved to the chat memory. Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
|
@sunyuhan1998 I admit I'm new to this project, but I don't think the solution here is the correct one. The system message is maintained in the |
|
Hi @sjohnr Thanks for your review! I think this issue might stem from the inconsistency in design between |
|
I'll look into it shortly and get back to folks. I appreciate all the hard work on the thread and the PR. |
|
@sunyuhan1998 thanks for looking into this issue. The memory advisors are not currently designed to persist the The reason why There is still a pending-design idea to introduce memory as a "first-class citizen" in |
|
@ThomasVitale Thank you for the detailed explanation. I now have a clear understanding of the original design intent, as well as the current state of |
|
I think there's a good reason not to save system prompts to memory. If Spring AI persisted them, you'd run into versioning issues. Imagine a user starts a conversation with one system prompt, you update it a few days later, and then they come back with a follow-up question. Which version should be used - the original or the updated one? I don't have a strong opinion, but it seems like not saving the system prompt actually has benefits here. |
As discussed in the issue, the current implementation of
MessageChatMemoryAdvisordoes not save theSystemMessageintoChatMemory, which is clearly a BUG.This PR fixes the issue by checking, when adding chat memory, whether the current conversation is the first turn or whether the current
SystemMessagediffers from the previous one. If either condition is met, theSystemMessagewill be added to the chat memory.Fixes #4170