Skip to main content

Context & Memory

Mesachat maintains conversation context so AI agents can provide relevant, coherent responses over time.

Context Window

The context window determines how much conversation history is included with each AI request. This is configurable at multiple levels:

ScopeDescription
GlobalDefault for all conversations
TenantOverride for a specific tenant
BotOverride for a specific bot
UserOverride for a specific user

Resolution follows the most-specific-wins pattern: User > Bot > Tenant > Global.

How Context is Assembled

For each incoming message, Mesachat:

  1. Retrieves recent messages from hot storage (PostgreSQL)
  2. If needed, fetches archived messages from cold storage
  3. Assembles the context within the configured window size
  4. Includes system prompts and agent instructions

Semantic Memory

Beyond raw conversation history, Mesachat supports semantic memory — AI-indexed memories that persist across conversations:

  • Long-term facts the user has shared
  • Preferences expressed over time
  • Key decisions from past conversations

Hot & Cold Storage

Mesachat uses a tiered storage architecture for optimal performance:

  • Hot tier (PostgreSQL) — Recent messages for fast context assembly
  • Cold tier (Object Storage) — Archived messages for long-term retention

Messages are automatically archived based on configurable retention policies.

GDPR Compliance

Mesachat supports GDPR data management:

  • Per-tenant encryption keys for crypto-shredding
  • Deletion requests tracked in an immutable audit log
  • Message tombstones for logical deletion