Memory Consolidation
Overview
The Memory Consolidator is a scheduled Cloudflare Worker that aggregates approved triage items into consolidated memories. It bridges the gap between individual triage candidates and durable organizational knowledge. File:services/knowledge/src/memory-consolidator.ts
Schedules
Hourly Consolidation
- Fetch approved triage items from last hour
- Group by category/topic
- Generate topic summary using Think service (Workers AI fallback)
- Write
consolidated_memorieswith typetopic
Daily Consolidation
- Fetch approved triage items from last 24 hours
- User-level: Group by user, generate user summaries
- Account-level: Group by account, generate account summaries
- Send health signals for at-risk accounts
- Cleanup memories beyond retention period
Weekly Consolidation
- Fetch consolidated memories from past week (topic + user + account types)
- Extract cross-cutting patterns using Think service
- Identify best practices
- Write pattern-type consolidated memory
- Update knowledge base with extracted patterns
Data Flow
Lock Mechanism
The Consolidator uses a Durable Object lock to prevent duplicate processing:acquire-lockwith TTL (3600 seconds)- Release after processing completes
- If lock not acquired, skip this cycle
Fallback Behavior
If the Think service is unavailable, the Consolidator uses a fallback summary:Retention
Old consolidated memories are cleaned up based onMEMORY_RETENTION_DAYS configuration. Default cleanup runs during daily consolidation.