#How to reset agent state or clear up memory.
1 messages · Page 1 of 1 (latest)
You can use stop() to terminate an agent session and ensuring the next interaction starts with fresh context.
For your reference!
i am using langgraph, any solution for it ?
In langgraph, the straightforward way is to simply start a new thread.
Stop the current run before starting another one (so the agent doesn’t keep running in the background). In CoAgents, this is typically a stop() on the running agent/session. And reset() from useCopilotChat clears the visible chat state. If your LangGraph agent uses thread persistence, start the next run on a new LangGraph thread ID (or delete/reset the old thread) so the agent has no prior state.
Please note - There’s also a recent issue where stop() didn’t fully stop LangGraph in some setups.
Is there anyway to include new chat option and chat History just line other ai , like gemini or openai ?
I believe what you are trying to do is to start a fresh chat. If that's the case, you can use the reset from useCopilotChat() hook in the Frontend. When calling reset() this will be reset the messages in the chat and hence you will be getting a fresh chat.
Doc reference:
https://docs.copilotkit.ai/reference/hooks/useCopilotChat#return-values
Thanks. Now I am clear. Do copilotkit have anything to keep chat History? Like any component that I can directly connect to database to manage user wise chats.