Skip to content

Memory Pipeline

The memory pipeline writes short-term memory (STM) after replies and long-term memory (LTM) through tool calls. Post-turn effects capture recent dialogue in the cache and schedule background summaries when due. The tool loop writes durable facts when the model invokes manage_long_term_memory.

Sub-pipelineStagesScope
STM01: Passive Capture
02: Background Summary
Working memory: in-process cache turns and durable short_term_memories rows
LTM01: Memory Creation
02: Memory Update & Delete
Permanent storage: database writes for server and personal memory tables
TypeStorageTTLWrite pathContext consumer
STM crude turnsIn-process cache (Map)Entry: 12 hours, or 24 when summary text existsPassive turn capture (storeShortTermMemory)STM context assembly
STM summary / categoriesIn-process cache and short_term_memories tableCache: 24 hours with summary text, otherwise 12 hours; database: separate retentionBackground summary or manual editSTM context assembly (takes priority over crude turns)
LTM server memoryserver_memories tablePermanentmanage_long_term_memory with createServer memories context assembly
LTM personal memorypersonal_memories tablePermanentmanage_long_term_memory with createParticipants context assembly
  • LTM writes. All manage_long_term_memory actions require self_teaching_enabled = true in TomoriState.config. When disabled, tool execution aborts without writing to the database.
  • STM automation. short_term_memory_enabled controls background summarization. Passive capture and recall remain available with automation off.
  • Triggerer privacy: if the triggering user has PrivacyLevel.FULL, passive STM capture aborts immediately.
  • Target user privacy: if a target user has PrivacyLevel.PARTIAL or PrivacyLevel.FULL, personal memory creation and updates return a privacy restriction error.
  • Persona lineage: LTM records are partitioned by persona_lineage_id. Creation is blocked if persona_lineage_id === 0 because zero is reserved for global memories.
  • STM writes. Background summaries commit the durable state before updating live cache entries.
  • Server LTM writes: Both tools invalidate Tomori state after database success. Server creation currently awaits its Discord notification first, so a notification failure can leave cached state stale. Update and deletion invalidate before notification.
  • Personal LTM writes: both tools call invalidateUserCache(userId) after successful database writes, so subsequent prompt assemblies fetch fresh records.