data/services/session_memory_service library

Classes

ManualExtractionResult
Result of a manual extraction.
SessionMemoryConfig
Configuration for session memory extraction thresholds.
SessionMemoryController
Main session memory controller — manages the extraction lifecycle.
SessionMemoryState
Mutable session memory state — tracks extraction lifecycle, thresholds, and the last summarised message.
SessionMessage
Simplified message for session memory processing.
SessionMessageBlock
A block within a session message.
TruncationResult
Result of truncating session memory for compact.

Constants

defaultSessionMemoryConfig → const SessionMemoryConfig
Default session memory configuration.
defaultSessionMemoryTemplate → const String
Default session memory template with sections for structured note-taking.

Functions

analyzeSectionSizes(String content) Map<String, int>
Parse the session memory file and analyse section sizes.
buildSessionMemoryUpdatePrompt(String currentNotes, String notesPath, Future<String> loadPrompt()) Future<String>
Build the session memory update prompt with section analysis.
countToolCallsSince(List<SessionMessage> messages, String? sinceUuid) int
Count tool calls since a given message UUID.
generateSectionReminders(Map<String, int> sectionSizes, int totalTokens) String
Generate reminders for sections that are too long.
getDefaultUpdatePrompt() String
Default update prompt for session memory extraction.
hasToolCallsInLastAssistantTurn(List<SessionMessage> messages) bool
Check if the last assistant turn in messages has tool calls.
isSessionMemoryEmpty(String content, Future<String> loadTemplate()) Future<bool>
Check if the session memory content is essentially empty (matches template).
roughTokenCountEstimation(String text) int
Rough token count estimation (same heuristic as TS: length / 4).
substituteVariables(String template, Map<String, String> variables) String
Substitute variables in a prompt template using {{variable}} syntax.
tokenCountWithEstimation(List<SessionMessage> messages) int
Estimate total token count across messages.
truncateSessionMemoryForCompact(String content) TruncationResult
Truncate session memory sections that exceed the per-section token limit. Used when inserting session memory into compact messages.