STM Sub-Pipeline
The short-term memory (STM) sub-pipeline maintains working memory across recent conversation turns. It stores recent dialogue in an in-process cache and records model-generated summaries and structured categories in the database.
The sub-pipeline provides two write paths:
| Stage | Trigger | Written state | Persistence |
|---|---|---|---|
| 01: Passive Capture | Post-turn, generation finished | Recent dialogue turns up to MAX_MESSAGES_PER_CHANNEL | In-process cache only; ensures scope identity row in database |
| 02: Background Summary | Background request after a reply reaches cadence | Distilled summary text or structured category key-value pairs | In-process cache and durable short_term_memories table |
Key design facts
Section titled “Key design facts”- Hybrid persistence: crude messages exist only in the in-process cache, while summaries, categories, the summary cursor, and cadence state are stored in the
short_term_memoriestable. Following a process restart, durable entries are hydrated with an empty crude message list, and message history repopulates as turns occur. - Dual-key scoping: writes index into both user-scoped (
shortterm:user:userId:channelId[:personaId]) and server-scoped (shortterm:server:serverId:channelId[:personaId]) keys. Direct message sessions create only the user-scoped entry. - Summary priority: same-channel context favors categories or summary text. Other-channel context can include raw messages alongside distilled content according to render mode. Passive capture preserves existing summaries.
- Deletion ownership: channel resets through
/refreshcallclearShortTermMemoryForChannel(), and user memory purges callclearShortTermMemoryForUser(). Both helpers evict the in-memory cache and delete rows from theshort_term_memoriestable in the background./personal nukedeletes user-scoped rows in the user-erasure transaction, then calls the cache-onlyinvalidateShortTermMemoryForUser()after commit. This evicts the user’s entries and hydration marker locally and through the invalidation bus. Server-scoped summaries remain shared server data.
Cross-references
Section titled “Cross-references”- Context assembly consumer: Short-Term Memory Context formats cached messages and summaries for prompt injection.
- Post-turn effects caller: Run Generation Turn: Post-Turn Effects triggers passive turn capture.