6 min read

Conversation Memory

The AI assistant keeps every conversation across sessions instead of starting fresh on each page load. A sidebar lists past conversations with auto-generated titles, and reopening one restores the full thread, including the tool calls and tool results the assistant ran. This is for anyone building a chat-style assistant on top of the kit who wants durable history without wiring up storage themselves.

Shipped in v0.2.0.

What it does

  • Persists threads. Each conversation and its messages are written to the database, scoped per tenant, so they survive reloads, logouts, and device switches.
  • Sidebar history. Past conversations appear in a sidebar in the assistant panel. Each entry is renameable and deletable.
  • Auto-titles. A new conversation gets a generated title sourced from the user’s first message, so the sidebar is readable without manual naming.
  • Lossless resume. Reopening a conversation replays the full message history — text, tool calls, and tool results. The AI SDK UIMessage.parts array is stored verbatim as JSON and round-tripped on resume, so a conversation that called a tool looks identical when you come back to it.

How to use it

Open the assistant, send a message, and a conversation is created and listed in the sidebar automatically. Click any sidebar entry to resume it with full history. Use the rename and delete controls on each entry to manage the list. No extra setup is required beyond having the AI assistant enabled.

Data model

Two Prisma models back the feature, both multi-tenant scoped by (id, userId, organizationId):

ModelHolds
ConversationTitle, owner (userId, organizationId), timestamps
MessageRole and the UIMessage.parts payload stored losslessly as JSON

Because every read and write is scoped by organizationId, one tenant can never see or resume another tenant’s threads.

API

All conversation operations go through /api/ai/conversations:

GET    /api/ai/conversations        # list the current tenant's conversations
POST   /api/ai/conversations        # create a conversation
GET    /api/ai/conversations/[id]   # get one conversation with its messages
PATCH  /api/ai/conversations/[id]   # rename
DELETE /api/ai/conversations/[id]   # delete

Messages are persisted by the chat endpoint at src/app/api/ai/chat/route.ts as the stream completes.

Auto-titles

After the first assistant turn, the service generates a title from the user’s first message using the cheapest configured model. The job is idempotent (it won’t overwrite an existing title) and fire-and-forget, so it never blocks or slows the chat response. See LLM Providers for how the configured-model list is ordered.

Limits

ConstantBehavior
MAX_CONVERSATIONS_PER_USERCaps how many conversations a user can keep
MAX_MESSAGES_PER_CONVERSATION2000 — appending beyond this returns HTTP 413

When a conversation is full, the client receives 413 and should prompt the user to start a new thread.

Key files

FileResponsibility
prisma/schema.prismaConversation and Message models
src/app/api/ai/chat/route.tsPersists messages as the chat stream completes
src/components/ai-assistant/ai-assistant-panel.tsxSidebar, rename/delete, resume UI
src/lib/repositories/conversation-repository.tsTenant-scoped conversation data access
src/lib/repositories/message-repository.tsTenant-scoped message data access
src/services/conversation-service.tsCreate/list/rename/delete + auto-title orchestration

How to extend

  • Change the limits. Adjust MAX_CONVERSATIONS_PER_USER and MAX_MESSAGES_PER_CONVERSATION, then handle the 413 on the client.
  • Change titling. Edit the title prompt or model selection in conversation-service.ts; keep it idempotent and fire-and-forget so chat latency is unaffected.
  • Add fields (pinning, archiving, folders): add a column to the Conversation model, extend the repository and service, and surface it in the panel and the /api/ai/conversations routes.
  • Persisting new message types: because UIMessage.parts is stored as JSON, custom parts round-trip automatically — no schema change needed.

To give the assistant durable knowledge beyond a single thread, see AI Memory and the retrieval-backed Knowledge Base.

Ready to build with VibeReady?

Get the full AI-native SaaS foundation with production infrastructure, AI development framework, and all integrations.

Get VibeReady — From $149