Illustrates the process of an AI agent's working memory being consolidated into episodic memory within a MemoryMesh, including vector index management and
sequenceDiagram
participant Agent
participant MemoryMesh
participant globalEventStore
Agent->>MemoryMesh: addWorkingMemory(threadId, content)
MemoryMesh->>MemoryMesh: store('WORKING', content)
MemoryMesh->>MemoryMesh: checkConsolidation(threadId)
alt Working memories > 5
MemoryMesh->>MemoryMesh: filter WORKING memories for thread
MemoryMesh->>MemoryMesh: generate summary string (heuristic)
MemoryMesh->>MemoryMesh: addEpisodicMemory('SYSTEM', {originThread, summary})
MemoryMesh->>MemoryMesh: purge old WORKING memories
MemoryMesh->>MemoryMesh: rebuildVectorIndex()
MemoryMesh->>globalEventStore: append({type: 'MEMORY_STORED', action: 'CONSOLIDATION'})
end
MemoryMesh->>MemoryMesh: garbageCollect()
alt Retention < 0.1
MemoryMesh->>MemoryMesh: move to coldMemories
MemoryMesh->>MemoryMesh: tombstone in active array
MemoryMesh->>globalEventStore: append({action: 'COLD_STORAGE_MOVE'})
MemoryMesh->>MemoryMesh: rebuildVectorIndex()
end
This diagram details how an Agent adds working memory to a MemoryMesh, which then stores and periodically checks for consolidation. If working memories exceed a threshold (e.g., 5), they are filtered, summarized into episodic memory, and old working memories are purged. The vector index is rebuilt, and events are logged. It also depicts garbage collection and moving memories to cold storage based on retention.
Use this diagram when designing, documenting, or explaining the memory management and consolidation strategies for AI agents, conversational systems, or any application requiring intelligent summarization and retention of interaction history.
This flow can be adapted by modifying consolidation triggers (e.g., time-based, event-driven), changing summarization heuristics, implementing different memory types (e.g., semantic, procedural), or integrating with external knowledge bases. The cold storage criteria and vector index rebuilding frequency can also be adjusted.