DEV Community

Dan Mercede
Dan Mercede

Posted on

Building Engram in 48 hours: what a memory engine taught me about forgetting

I entered the Qwen Cloud Global AI Hackathon's MemoryAgent track with a bias: I havespent months maintaining a typed memory system for my own AI agents (memory fileswith decay, an index under a hard size budget, contradiction notes). The track briefread like a checklist of the things that system taught me the hard way: efficientretrieval, timely forgetting, recall within limited context windows. So I productizedthe doctrine into an engine: Engram.

Three things earned their keep.

1. The budget is the feature. Most memory demos retrieve top-k and pray it fits.Engram scores every active memory (embedding similarity from text-embedding-v4,blended with retention, importance, and access frequency) and greedy-packs under ahard token budget, with backfill so a huge top memory does not starve the context.The packer has a property test over randomized pools: the selected set never exceedsthe budget. Writing that test first changed the design; the naive version failed it.

2. Forgetting needs a mechanism, not a cron job. Retention decays exponentiallyfrom last access with type-specific half-lives (episodes die in weeks, skills livefor months), scaled by importance. Recall refreshes retention, so what gets usedstays alive. Below the floor, a memory is marked decayed but never deleted; theaudit trail is the product too.

3. Contradictions are the hard 20 percent. New facts are checked against nearestneighbors and adjudicated by qwen3.7-plus at temperature 0 with strict JSON and afail-safe parser (a parse failure can never supersede anything). The subtle bug anadversarial review caught: my similarity gate was tuned too high, so "I moved toDenver" never even reached the adjudicator against "I live in San Diego" (they onlycosine at about 0.49 in 256 dims). Live probes, not intuition, set the threshold.

The meta-lesson: I ran an adversarial review pass that tried to refute 75 discreteclaims in my own README and submission against the code and live probes. It found aswapped argument pair feeding the adjudication prompt, the mistuned gate above, andhalf a dozen places where my wording was stronger than my evidence. An hour of beingrefuted is worth more than a day of polishing.

Engram is MIT-licensed, ships an MCP server so any agent can adopt it as a memorybackend, and runs on Alibaba Cloud with Qwen Cloud models end to end.

Code: https://github.com/OrionArchitekton/engram
Live: https://engram.orionbot.online

Top comments (0)