LightMem addresses the challenge of growing conversation history through intelligent multi-tier consolidation. By distilling dialogues, grouping by topic, and performing sleep-time consolidation, LightMem achieves 117x token reduction while maintaining semantic fidelity.
Awareness implements LightMem's consolidation strategy:
**Tier 1: Dialogue Distillation** - Extract key statements from each turn - Remove conversational fluff - Preserve factual content and decisions - Applied to turns older than 10 messages
**Tier 2: Topic-Aware Consolidation** - Group related turns by topic - LLM summarizes each topic cluster - Link to original turns for drill-down - Applied to conversations > 100 turns
**Tier 3: Sleep-Time Consolidation** - Full conversation summary for inactive chats - Extract entities, relationships, outcomes - Mark original messages as `supersededBy: summaryId` - Triggered after 30 days inactivity
- Dramatically reduce context window usage
- Maintain semantic search accuracy
- Preserve ability to drill into details
- Enable infinite conversation length
// LightMem consolidation in Awareness
async function consolidateOldMemories() {
// Tier 1: Distill old dialogue
const oldMessages = await getMessagesOlderThan(10);
for (const msg of oldMessages) {
const distilled = await llm.extract({
prompt: "Extract key facts from this message",
message: msg.content
});
await createConsolidatedMemory({
type: "distilled",
original: msg.id,
content: distilled,
compression: msg.content.length / distilled.length
});
}
// Tier 2: Topic-aware grouping
const topics = await clusterByTopic(oldMessages);
for (const [topic, messages] of topics) {
const summary = await llm.summarize({
topic,
messages: messages.map(m => m.content)
});
await createTopicSummary({ topic, summary, messages });
}
}Memory efficiency and consolidation - compress old conversations dramatically
Virtual context management, heartbeat mechanism, OS-inspired memory paging
Two-phase memory pipeline, conflict resolution (ADD/UPDATE/DELETE/NOOP), graph-enhanced variant
Reflection tokens ([Retrieve], [IsRel], [IsSup], [IsUse]), adaptive retrieval