Error when using Gemini with zep - System message should be the first one

Describe the problem/error/question

I’m using Gemini plus the ZEP database, and getting this error System message must be first
It worked with some messages and now it’s giving this error

What is the error message (if any)?

System message should be the first one

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.45.1
  • **Database (default: postgres):postgres
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):Docker
  • **Operating system:linux 20.04

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:

Hi @Ruan17 thank you for reaching out! Is there any additional error context included in the AI Agent when you test the workflow?

the context would be. I start the conversation, after a few messages, this error starts to appear. haven’t found the cause yet

I know exactly what’s causing it. I just don’t know how to fix it.
The problem is that in node AI Agent you have your own ‘System message’ and after several messages ZEP makes a summary of your previous messages and sends it not as a dialogue history but as another ‘System message’. Since there can only be 1 System message and it must always be the first one. In your case there are 2 of them. That is why there is an error. I don’t know how to fix it. If someone can help me, I will be grateful.

1 Like