Skip to content

STM Sub-Pipeline

Manages the short-term memory cache — an in-process Map that stores the last 10 conversation turns per channel/persona pair. Two write paths exist:

StageFileTriggerWhat it writes
01-passive-capture.mdstoreShortTermMemoryPost-turn, alwaysCrude conversation (last 10 messages + new persona response)
02-summary-upgrade.mdupdateShortTermMemorySummaryMid-turn, LLM tool callLLM-authored summary that replaces the crude conversation
  • Cache-only — STM is never written to the database. A process restart clears all STM entries. Cross-restart persistence is not a design goal.
  • 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 summary field when present, ignoring the messages array. The passive capture (stage 01) preserves any existing summary when overwriting the messages array.
  • One upgrade per turnstreamingContext.disableShortTermMemoryUpdate is set to true after the first successful update_short_term_memory tool call, preventing the LLM from calling it again within the same tool-loop iteration.