AI Agent Memory Tool problem (Win Buffer and Postgres)

##Hi guys, I’ve been encountering an issue for a couple of days. To give some context, I’m self-hosted, and I use Ngrok for my Webhook integration.

This is my workflow:

After several attempts, I can confirm that the issue lies with the session ID key in the memory tool. I’ve tried it with both Windows and PostgreSQL. I’m using this variable as the session ID key, is a phone number.:
{{ $(‘Webhook’).item.json.body.from }}

The first interaction works fine, but after that, I get an error:
Issues: * Bad request - please check your parameters (Invalid value for ‘content’: expected a string, got null.)

However, if I use this for the session ID key then, no error occurs.:
{{ $(‘Webhook’).item.json.body.from + ’ ’ + new Date().toISOString() }}

The problem with this approach is that it doesn’t remember anything, and the AI agent can’t perform its tasks properly.

  • **Running n8n via Docker
  • **Operating system: Windows

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Can you check if the session ID is actually arriving in every request, please?

If yes, then try to use {{ $('Webhook').item.json.body.from.toString() }} instead and see if that works.

If my reply answers your question, please remember to mark it as a solution.

I can confirm that it is happening on my end as well. In my case, it involves the Slack User ID, and it always fails on the second attempt.

I noticed that as long as the key exists in Redis (in my case), it will always fail.
If I replace the session ID with “client_msg_id,” which always changes, it will work; however, in that case, the chat memory won’t remember the previous messages per user.

That’s strange; copying all the settings to a new workload resolved the issue.