Skip to content

Session Context

Luna keeps short-term Discord conversation context per channel or thread. The Discord channel id is the session boundary, and Discord threads have their own channel ids, so follow-ups in one place do not leak into another.

How It Works

  • The bot stores recent user and assistant turns in the existing channel_messages table in Luna's SQLite bot state database.
  • Every model call starts with the runtime system prompt from LUNA_RUNTIME_PROMPT.md or the configured LUNA_RUNTIME_PROMPT_PATH.
  • The model call then receives the bounded recent session messages, preserving their roles, followed by the current user turn.
  • LUNA_HISTORY_MAX_TURNS controls the rolling window. The default is 6 turns, which means at most 12 stored session messages are included after the system prompt.
  • LUNA_SESSION_MESSAGE_MAX_CHARS bounds each stored message. The default is 4000 characters.

Commands

  • luna session status shows safe metadata for the current Discord channel/thread, including counts and recent roles. It does not expose raw message text, tokens, API keys, or secrets.
  • luna reset session clears only the current Discord channel/thread session.

Boundaries

Session context is short-term working context. It exists so Luna can answer follow-ups like "the commands you just listed" inside an active Discord conversation.

Persistent memory is durable bot state, such as jobs, confirmations, task state, or other explicit records that survive beyond a chat window for operational reasons.

Governed long-term memory is a future controlled memory layer for durable user or project facts. It needs explicit extraction rules, confidence thresholds, review/deletion behavior, and clear policy boundaries before live promotion.

Future pgvector retrieval is a search layer for governed long-term memory. It should retrieve relevant approved facts, not silently promote raw chat into memory. Session context does not require pgvector and does not perform vector retrieval.

Current Non-Goals

  • No live memory promotion from session chat.
  • No pgvector dependency for session context.
  • No autonomous recursion or background reflection loop.
  • No cross-channel or cross-thread context sharing.