spring-projects / spring-projects/spring-ai
MessageChatMemoryAdvisor and PromptChatMemoryAdvisor lack a way to pass custom Message metadata
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Expected Behavior
I am trying to implement a persistent ChatMemory myself. In my persistent storage, I want each Message to have a custom unique primary key and other accompanying metadata (I think this is also a common requirement for many people). I will specify this when I construct the ChatClientRequestSpec, and then get it from the Message parameter when implementing the ChatMemory add method.
Current Behavior
I found that there is no part in the parameters of the ChatMemory add method that can carry custom metadata for the Message. Although the metadata property is provided in AbstractMessage, unfortunately, MessageChatMemoryAdvisor and PromptChatMemoryAdvisor create a new Message object when calling the add method, and do not pass any Metadata properties.
Context
I think I can use Advisor's adviseContext to achieve this goal. I can pass the metadata in by specifying params when constructing ChatClientRequestSpec, and then get them in MessageChatMemoryAdvisor and PromptChatMemoryAdvisor by getting the adviseContext of AdvisedRequest, add them to Message, and pass them to ChatMemory.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading MessageChatMemoryAdvisor and PromptChatMemoryAdvisor, focusing on how they create Messages before calling ChatMemory.add. Trace the AdvisedRequest advice context and the ChatMemory add method to understand the proposed metadata path. Done means custom metadata supplied through ChatClientRequestSpec reaches the Message received by a persistent ChatMemory implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- ai, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100