[BUG] Short term memory is not working
Describe the bug Buffer Memory is always empty, only "history" field works.
To Reproduce Steps to reproduce the behavior:
- Create any flow with buffer memory
- Make an API request with the same "chatId"
- You will see it is not going to remember anything.
Expected behavior Flow should remember the history with the help of Buffer Memory.
Screenshots
Setup
- Docker
- Latest pull from github
- Api Request
@HenryHengZJ i cant see any breaking change in the documentation. Is this expected? Do I have to keep the history by myself ? If so why do we have Buffer Memory? Thanks in advance.
yeah that has always been the case. If you using Buffer Memory with API, you have to provide history array, there is no session id. Buffer Memory is just an array of messages.
Is this a recent change? Because I have never set and sent history in the request before.
Is this a recent change? Because I have never set and sent history in the request before.
yes we changed to use the new method from lanchain (LCEL). but this shouldnt affect it, because by right buffer memory doesnt have session to capture mutiple different conversations. Ideally we can implement our own logic for that but its not there yet
@HenryHengZJ It is hard to manage the history on the app side ( which means my own app not the flowise ).
"because by right buffer memory doesnt have session to capture mutiple different conversations" I expect that the buffer memory keeps its record depending on the memoryKey or chatId. Which is how it was before via memoryKey.
Other than that the main issue was that the buffer memory was not working at all in case I didn't give it a history via API request. As default, it should have an array of history data in the logs with the name of memoryKey. Right now it is always an empty array.
Theoretically we can change the code to have buffer memory to fetch the chat history using chatId since chatId is the Flowise sessionId. I will add that to our backlog item to work on
Theoretically we can change the code to have buffer memory to fetch the chat history using
chatIdsincechatIdis the Flowise sessionId. I will add that to our backlog item to work on
I would rather use the (memoryKey || chatId || sessionId) approach.
Other than this i don't want the problem that prompted me to open this bug entry to be missed @HenryHengZJ
BufferMemory previously worked by itself when MemoryKey was provided (which always has got a default value). We did not need to provide History data. BufferMemory created and tracked the History data itself. This behavior has completely changed. Whether we provide BufferMemory data or not, I have to keep and transmit the History data myself, because BufferMemory no longer fills the History data by itself. For those who will migrate from the old version and use API services, this is a breaking change. This may need to be in the documentation.
the reason why memoryKey wont work is because when you shut down and restart the apps, the memory will be gone, as its only stored in memory. So i do think that the ideal approach is to retrieve all chat messages using chatId
Well, that is why it is called "in memory short-term memory", I understand this for sure.
I would still keep the memoryKey to have multiagent history.
Think of that we are trying to achieve a multi-agent approach something like crewAI, it will need a router and memory for each agent. It will be a single chat ( with a single chatId ) with multiple agents which uses a different memoryKey. As you see memoryKey becomes useful for such use cases.
Of course, there could be many other possible ways to achieve CrewAI-like solutions with interconnected flows.
Despite the bug I mentioned earlier, we could open a new post on discussions, would that be appropriate @HenryHengZJ ?
fixed via PR