Background service for semantic summarization and compaction of long-term agent memories to maintain context efficiency.
As AI agents interact with users over long periods, their "memory" (history, context) can grow large and redundant. agent-memory-compactor solves this by:
- Semantic Analysis: Classifying memory importance using LLMs.
- Temporal Clustering: Grouping related memories within time windows.
- Semantic Compaction: Using LLMs to summarize clusters of low-importance memories into high-density facts.
- Critical Preservation: Keeping high-importance memories in their raw form for precision.
- Production-Ready: Written in TypeScript with full type safety.
- Zo Integration: Built specifically for the Zo Computer ecosystem, using the internal
/zo/askAPI. - Configurable: Adjustable thresholds for importance and compaction frequency.
- Daemon Mode: Can run as a background service to continuously maintain efficiency.
git clone https://github.com/Retsumdk/agent-memory-compactor.git
cd agent-memory-compactor
bun installbun run src/index.ts --add "User mentioned they like dark mode." --tags "ui,preference"bun run src/index.ts --compactbun run src/index.ts --listbun run src/index.ts daemon --interval 60The service uses a config.json file:
{
"threshold": 8,
"maxEntriesPerCluster": 20,
"compactionIntervalDays": 7,
"storagePath": "./data/memories.json"
}CLI (index.ts) -> Compactor (compactor.ts) -> MemoryStore (store.ts)
-> ZoClient (client.ts) -> Zo API
MIT License
Built by Retsumdk