Developer Builds Memory-Efficient AI Agent Using Decay Math
- •Tombri Bowei created Synapse, an AI memory agent using decay math to manage and delete outdated information.
- •Synapse maintained 117 active memories and 130–170 tokens per query, compared to the naive baseline's 220 memories and 2000+ tokens.
- •A 110-turn simulation revealed a timestamp bug that favored stale data, leading to a 71% recall accuracy versus 95% for the baseline.
Tombri Bowei developed Synapse, an AI memory agent designed for the Global AI Hackathon Series on Qwen Cloud, to address inefficiencies in traditional retrieval-based memory systems. Unlike standard agents that store every message in a vector database, Synapse incorporates decay math, semantic consolidation, and contradiction detection to manage information life cycles. The system calculates a salience score for each memory, determined by the formula salience(t) = importance_score (1 + log(1 + recall_count)) exp(-lambda hours_since_last_recall), where lambda is derived from a half-life variable. Episodic details typically decay in 72 hours, while semantic facts last 30 days.
The architecture features a background sleep pass that clusters repeated mentions and retires stale facts when new information supersedes them. Bowei implemented these features using Qwen-max and Qwen3.7-plus models, with text-embedding-v3 for vector operations. During a simulated 40-day, 110-turn conversation benchmark, Bowei identified a bug where functions defaulted to real-time timestamps instead of the simulated time, causing the agent to prioritize stale data. This was resolved by explicitly threading simulated time through all timestamp-dependent logic.
Benchmarking Synapse against a naive baseline revealed distinct performance differences. The Synapse agent maintained a stable memory count of approximately 117 active items, whereas the baseline grew linearly to 220 items. Token costs per query for Synapse remained between 130 and 170 tokens, compared to a spike exceeding 2000 tokens for the baseline. While Synapse initially achieved a 71% recall accuracy compared to 95% for the naive baseline, Bowei identified and addressed flaws in the similarity pre-filter gate, which had a 0.59 similarity score against a 0.75 requirement, and the re-ranking formula. The project is currently deployed on Alibaba Cloud ECS and is available as an MIT-licensed repository.