Architecture: In which MongoDB database/collection should all chat session...

Documentation for Sessions

🏗️ Architecture: In which MongoDB database/collection should all chat session...

Date: 2026-03-03
Time: 15:50:22 UTC
Session: gspace1-166.5
Agent: backend
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

In which MongoDB database/collection should all chat sessions (Panel + Vitto) be stored?

Task: Session 166.3: Chat storage database decision


🎯 Decision Made

Chosen:

Keep all chat sessions in ai-agents database, chat_sessions collection (existing). Both Panel and Vitto chats use the same collection, differentiated by the source field ('panel' | 'vitto' | 'embedded' | etc.) and spaceId for multi-space scoping.

Options Considered:

  1. Keep in ai-agents.chat_sessions (current)
  2. Move to new dedicated chat-persistence database
  3. Move to vitto-mind alongside Vitto engine data
  4. Split active/archived across ai-agents and ai-archive

💭 Reasoning

4 alternatives evaluated: (1) Keep in ai-agents.chat_sessions — already works, ai-agents is the AI data hub (29 collections, 256 indexes), no migration needed; (2) Dedicated database — overkill, adds connection overhead for no benefit; (3) Move to vitto-mind — wrong cluster (vitto.urgh6ow.mongodb.net vs gograbspace.dgqij2t.mongodb.net), would require cross-cluster queries; (4) Split active/archived across ai-agents/ai-archive — adds query complexity for the same data type. The status field index (active/archived/cold) on the same collection achieves tier separation without cross-database joins. The conversation_genomes data is embedded in each session document (genome field) rather than a separate collection, keeping queries simple. ai-agents is already the established hub for AI operational data (decisions, embeddings, agent memories), and chat sessions are AI operational data. The ai-memory database (175MB) stores user long-term memories — different concern. The ai-archive database (16KB) exists but is essentially empty and better reserved for bulk cold storage in the future.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation