Build AI Agents ThatRemember, Learn & Evolve.
Private, persistent memory for .NET AI agents. Semantic, episodic and procedural memory types with automatic extraction, consolidation, time-decay scoring, and multi-user isolation. 100% on-device RAG. Zero cloud dependency.
Memory Lifecycle
Three Memory Types
Semantic
Facts & knowledge
Episodic
Events & interactions
Procedural
How-to & workflows
Stateless Agents Forget. Yours Won't.
Most AI agents treat every conversation as their first. They forget user preferences, lose track of project context, and repeat the same questions. Agent memory solves this by giving your agents persistent, structured recall that survives across sessions.
From Stateless to Stateful in One API
LM-Kit's AgentMemory integrates directly with MultiTurnConversation and the Agent framework. Memory is RAG-backed, KV-cache aware, and designed for production multi-user deployments.
Automatic Learning
The agent extracts facts, events, and procedures from every conversation turn without manual intervention.
Private by Design
All memory storage and retrieval runs 100% on-device. No data leaves your infrastructure. HIPAA and GDPR ready.
Persistent Across Sessions
Serialize memory to disk and restore it at any time. Share memory states between agents and deployments.
Without Agent Memory
LM-Kit Agent Memory
Persistent, private, structured memory that lives on your hardware. Three memory types, automatic extraction, smart consolidation, and multi-user isolation out of the box.
Three Types of Memory, One Unified API
Modeled after human cognitive memory. Each type serves a distinct purpose, enabling agents to store the right kind of knowledge in the right way.
Semantic Memory
General knowledge, facts, and definitions that remain true over time. The foundation for grounded, accurate responses. User profiles, product catalogs, domain expertise, and configuration details.
Episodic Memory
Specific events, interactions, and experiences anchored in time. Enables agents to reference past conversations and track evolving situations. Support tickets, project milestones, and conversation history.
Procedural Memory
Learned processes, workflows, and step-by-step procedures. Enables agents to remember how users like things done. Runbooks, deployment checklists, troubleshooting guides, and personal routines.
Everything for Production Memory
From automatic learning to enterprise-grade capacity management. Every feature you need to ship memory-powered agents at scale.
Automatic Extraction New
LLM-based fact extraction classifies memories by type and importance. Deduplication via vector similarity prevents redundant entries.
Memory Consolidation New
LLM-powered clustering merges semantically similar memories into concise summaries. Reduces storage while preserving knowledge.
Time-Decay Scoring New
Exponential decay ensures recent memories rank higher in retrieval. Configurable half-life from hours to months.
Multi-User Isolation New
UserScopedMemory namespaces data by user ID. One shared store, fully isolated retrieval, per-user cleanup.
Capacity & Eviction New
Set maximum entries and choose eviction policies: oldest first, lowest importance first, or a combined strategy. Cancel evictions via events.
Serialize & Restore
Persist memory to binary files and reload across sessions, deployments, and machines. Share memory states between agents.
Memory in Five Lines of Code
Add persistent memory to any agent or conversation. Automatic extraction, consolidation, multi-user scoping, and persistence are all configured through simple properties.
using LMKit.Model; using LMKit.Agents; using LMKit.TextGeneration; // Load models var chatModel = LM.LoadFromModelID("qwen3:8b"); var embedModel = LM.LoadFromModelID("qwen3-embedding:0.6b"); // Create memory and store facts var memory = new AgentMemory(embedModel); await memory.SaveInformationAsync("profile", "User prefers dark mode", "prefs"); await memory.SaveInformationAsync("profile", "User's name is Sarah", "name"); // Attach to conversation - memories are recalled automatically var chat = new MultiTurnConversation(chatModel) { Memory = memory }; var response = chat.Submit("What do you know about me?"); // Agent recalls: "Your name is Sarah and you prefer dark mode."
// Enable automatic fact extraction from conversations var memory = new AgentMemory(embedModel) { ExtractionMode = MemoryExtractionMode.LlmBased, ExtractionModel = chatModel, MaxExtractionsPerTurn = 5, DeduplicationThreshold = 0.85f }; // Inspect what gets extracted before storage memory.BeforeMemoryStored += (sender, e) => { foreach (var m in e.Memories) Console.WriteLine($"[{m.MemoryType}] {m.Text}"); }; var chat = new MultiTurnConversation(chatModel) { Memory = memory }; // Every turn, the agent auto-extracts and stores memories chat.Submit("I'm working on the Acme project. I prefer TypeScript."); // Extracted: [Semantic] User prefers TypeScript // Extracted: [Episodic] User is working on the Acme project
using LMKit.Agents.Memory; // Shared memory store for all users var sharedMemory = new AgentMemory(embedModel); // Create user-scoped views - data is fully isolated var aliceMemory = new UserScopedMemory(sharedMemory, "alice"); var bobMemory = new UserScopedMemory(sharedMemory, "bob"); // Store per-user data await aliceMemory.SaveInformationAsync("prefs", "Prefers dark mode", "theme"); await bobMemory.SaveInformationAsync("prefs", "Prefers light mode", "theme"); // Apply user scope before conversation - only their data is recalled aliceMemory.ApplyFilter(); var chat = new MultiTurnConversation(chatModel) { Memory = sharedMemory }; // Persist all users in a single file sharedMemory.Serialize("all_users_memory.bin");
// Full memory lifecycle: extraction, capacity, decay, consolidation var memory = new AgentMemory(embedModel) { ExtractionMode = MemoryExtractionMode.LlmBased, ExtractionModel = chatModel, MaxMemoryEntries = 500, EvictionPolicy = MemoryEvictionPolicy.OldestLowestImportanceFirst, TimeDecayHalfLife = TimeSpan.FromDays(30) }; // Consolidate similar memories into concise summaries memory.ConsolidationSimilarityThreshold = 0.7f; var result = await memory.ConsolidateAsync(chatModel); Console.WriteLine($"Merged {result.ClustersMerged} clusters, freed {result.EntriesRemoved} entries"); // Summarize a conversation into episodic memory var summary = await memory.SummarizeConversationAsync(chat.ChatHistory, chatModel); // Persist and restore memory.Serialize("agent_memory.bin"); var restored = AgentMemory.Deserialize("agent_memory.bin", embedModel);
See Memory in Action
Runnable samples that demonstrate every memory capability. Clone, build, and ship.
Persistent Memory Assistant
Full-featured demo showcasing auto-extraction, capacity limits, eviction, consolidation, conversation summarization, time-decay, and persistence.
MemoryMulti-Turn Chat with Memory
Side-by-side comparison: conversations with and without memory. Pre-built customer profile with semantic recall.
RAGRAG Chatbot
Chat with eBooks, PDFs, and documents using retrieval-augmented generation. The foundation of memory-powered document intelligence.
SessionPersistent Session
Save and restore full conversation state to disk. Resume sessions across application restarts with full context.
AgentResearch Assistant
ReAct planning agent with web search. Combine memory with reasoning and tools for complex multi-step research tasks.
IntegrationSemantic Kernel + Memory
LM-Kit.NET as the LLM backend for Microsoft Semantic Kernel with persistent memory integration.
Step-by-Step Implementation Guides
Detailed walkthroughs covering every aspect of agent memory, from basic setup to advanced production patterns.
Key API Classes
The core types that power agent memory in LM-Kit.NET.
AgentMemory
Core memory storage, retrieval, extraction, and consolidation
UserScopedMemory
Multi-user isolation with namespace prefixing
MemoryType
Semantic, Episodic, Procedural enum
MemoryExtractionMode
None or LlmBased automatic extraction
MemoryEvictionPolicy
Oldest, LowestImportance, or combined
MultiTurnConversation
Conversation engine with Memory property
Core Concepts
Foundational concepts behind agent memory, retrieval, and knowledge management.
Related Capabilities
AI Agent Orchestration
Planning strategies, multi-agent workflows, and the full agent framework that memory powers.
Explore AI AgentsMCP & Tools
Combine memory with tool calling and MCP servers. Agents that remember and act.
Explore ToolsConversational AI
Multi-turn conversations, agentic reasoning, and the chatbot capabilities powered by agent memory.
Explore ChatbotsDocument Intelligence
Document processing agents that remember previous analysis results and build persistent knowledge bases.
Explore DocumentsRAG Pipelines
The retrieval-augmented generation engine that powers agent memory's semantic search and recall.
Explore RAGPrivacy & Compliance
Why on-device memory matters for HIPAA, GDPR, and enterprise deployments with zero data leakage.
Learn MoreBuild Agents That Never Forget
From stateless chatbots to intelligent assistants with persistent, private, structured memory. Add long-term recall to your .NET agents today.