Get Free Community License
Agent Memory

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.

3 Memory Types Auto-Extraction 100% On-Device Multi-User

Memory Lifecycle

1 Conversation turn processed
2 LLM extracts facts, events & procedures
3 Deduplicated & stored in vector index
4 Recalled via semantic search on next turn

Three Memory Types

Semantic

Facts & knowledge

Episodic

Events & interactions

Procedural

How-to & workflows

100%
On-Device
3
Memory Types
RAG
Vector Search
Multi-User
Isolation
Why Memory Matters

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

Agent asks the same onboarding questions every session
User preferences lost after every restart
Document processing agents forget previous analysis results
No personalization across multi-user deployments
Cloud memory services leak sensitive data and add latency

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.

Memory Types

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

Facts & Knowledge

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.

User preferences Product specs Domain rules Contact info

Episodic Memory

Events & Interactions

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.

Past conversations Meeting notes Support tickets Project events

Procedural Memory

How-To & Workflows

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.

Deployment steps Approval flows User routines Troubleshooting
Capabilities

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.

Code Examples

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);
Glossary

Core Concepts

Foundational concepts behind agent memory, retrieval, and knowledge management.

Build Agents That Never Forget

From stateless chatbots to intelligent assistants with persistent, private, structured memory. Add long-term recall to your .NET agents today.

Need help with memory architecture? Talk to an expert