Chat Memory Manager node allways returns all the chat history with Postgres Chat Memory

When using the Chat memory manager node with the Postgres Chat memory, the option in the latter node to limit the Context Window Length, say to 1 or 5, doesnt do anything. Whatever value I put the Chat Memory Manager will return all the messages in the postgres database for that id. I can still filter them later on, but I pressume this is not how it is supposed to work.

anyway, thanks a lot for you hard work. loving n8n so far.
cheers

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.75.2
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

This is a known issue where the Chat Memory Manager node returns all messages from the Postgres Chat Memory regardless of the Context Window Length setting. I found two workarounds. 1)Use a function node limiting up 20 items, or 2)Limit node. One of those could be placed after the Chat Memory node.

Using Function Node
Set a custom node and insert the custom script.

Use a Limit node
Use the Limit node after the Chat Memory Manager node.

  • Set “Max Items” to 20
  • Set “Keep” to “Last Items” to retain the most recent messages

These are workarounds until it’s fixed. I read somewhere that the n8n is aware of this issue and there’s an ongoing discussion about fixing the Context Window Length functionality in the Postgres Chat Memory node.

thanks, if the team is aware I will just wait for an update