Hi CopilotKit Team! 👋
I’m currently evaluating **CopilotKit **for a production use case and I've run into a persistence issue. While chat history works during an active session, it disappears after a frontend server restart.
My Tech Stack:
Backend: Python with Agno Framework (v2.13)
Database: Postgres (Verified: chat sessions are correctly stored here)
Frontend: Next.js (v15/16) + CopilotKit (v1.50)
The Setup: In page, I have a sidebar on the left showing a list of past chat sessions. On the right, I use the <CopilotSidebar />. When a user selects a session from my left panel, the past chat history loads perfectly into the sidebar. I haven’t written any custom "history loading" logic—CopilotKit seems to handle this automatically when the session is active.
The Issue:
I start a chat and see it saved in Postgres.
I switch sessions; history loads fine.
If I restart the frontend server and try to load that same session again, the **CopilotSidebar **is completely empty, even though the data is still in my Postgres DB.
What I've Checked:
The session data exists in the database.
The backend is connected and healthy.
It seems like the link between the frontend's session reference and the backend's persisted state is being lost on refresh. Has anyone else faced this with the Agno integration? How should I ensure the frontend "re-attaches" to the existing Postgres thread after a hard reload?
Here is the partial code how I am using it in my application.
layout.tsx:
<CopilotKit
runtimeUrl={/api/copilotkit}
agent="my_agent" key={threadId}
threadId={threadId}
>
<ChatHistorySidebar
currentId={threadId}
onSelect={(id) => setThreadId(id)}
/>
<div className="w-full">{children}</div>
</CopilotKit>
page.tsx
<CopilotSidebar defaultOpen={true} />
Would love some guidance here so I can confidently move this to production!