STM Sub-Pipeline
Manages the short-term memory cache — an in-process Map that stores recent
conversation turns per channel/persona pair up to the configured limit. Two
write paths exist:
| Stage | File | Trigger | What it writes |
|---|---|---|---|
01-passive-capture.md |
storeShortTermMemory |
Post-turn, always | Crude conversation capped by SHORT_TERM_MEMORY_MAX_MESSAGES_PER_CHANNEL |
02-summary-upgrade.md |
updateShortTermMemorySummary |
Mid-turn, LLM tool call | LLM-authored summary written to the cache and database |
Key design facts
Section titled “Key design facts”- Hybrid persistence — crude messages exist only in the in-process cache, while summaries, categories, and cadence state are stored in the database. After a process restart, durable fields are hydrated with an empty crude message list; crude history repopulates channel by channel as the bot replies.
- Dual-key scoping — every write creates (or updates) two cache entries:
one user-scoped (
shortterm:user:userId:channelId[:personaId]) and one server-scoped (shortterm:server:serverId:channelId[:personaId]). DM sessions get only the user-scoped key. - Summary takes priority — the context-build stage renders the
summaryfield when present, ignoring themessagesarray. The passive capture (stage 01) preserves any existing summary when overwriting the messages array. - One upgrade per turn —
streamingContext.disableShortTermMemoryUpdateis set totrueafter the first successfulupdate_short_term_memorytool call, preventing the LLM from calling it again within the same tool-loop iteration.
Cross-references
Section titled “Cross-references”- Intent gate that may suppress stage 02: → memory pipeline README
- Read side (both stages): → context-build STM stage
- Tool-loop that triggers stage 02: → tool-loop Stage 02
executeToolCall - Post-turn effects that trigger stage 01: → chat per-turn Stage 04