Unable to clear in context memory for an agent

Hello,
When I create an agent with a username and session id and ask a couple of questions, I can see the memory being updated and stored.

Now when I create a new agent with a new user id and new session id, the messages from the previous user context is retained.

Is there a way to clear the memory?

Here’s the code snippet:


(I created a new agent with the same code as above but new user name and session id) - Post did not allow me to attach two images.

Shouldn’t the two agents have separate memory? But the history from one agent’s messages is being considered for the second agent with a new user id.

I’d appreciate some help in understanding why this issue occurs and any documentation/code examples to help resolve this.

Hi @vswaminathan
Thank you for reaching out and using Phidata! I’ve tagged the relevant engineers to assist you with your query. We aim to respond within 24 hours.
If this is urgent, please feel free to let us know, and we’ll do our best to prioritize it.
Thanks for your patience!

Hey @vswaminathan, you can use .clear() function to clear the memory. You will have to call it as agent_memory.clear() according to your code.

Okay, Thanks. Appreciate it. How do I get the data to be stored in agent_memory’s db. Session memory gets updated and stored persistently but the agent_memory’s db is always empty. Should I write some code for it to store context within persistent memory? In my agent code I have already given it agent_memory and agent_storage as seen above. Should it not populate that db automatically?

Looking forward to hearing from you. Thanks.

Hello @vswaminathan !

To populate the agent memory table, you need to set set create_user_memories=True and create_session_summary=True in your memory config.

Some docs on memory here. Please let us know if you have any questions

I have already set these parameters as true in the config.

It still does not update the table.

@vswaminathan can you add debug_mode=True to your agent config and share the output here with us? It will help us see under the hood as to what’s happening