跳转到内容

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:

StageFileTriggerWhat it writes
01-passive-capture.mdstoreShortTermMemoryPost-turn, alwaysCrude conversation capped by SHORT_TERM_MEMORY_MAX_MESSAGES_PER_CHANNEL
02-summary-upgrade.mdupdateShortTermMemorySummaryMid-turn, LLM tool callLLM-authored summary written to the cache and database
  • 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 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 turn: streamingContext.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.