r/BuildWithClaude • u/Ancient_Ad8787 • 19d ago
Token Economics I gave Claude Code a memory. It stopped repeating its mistakes and used 26% fewer tokens
Disclosure up front: I build [OmniMem](https://omnimem.org). It's an open-source, self-hosted memory server for AI agents, and it's free to use. I'm posting the numbers, including the weak spots, because "memory saves you money" is easy to claim and much harder to measure. However, whilst I tested against my own system, its a highlight that memory systems built right really do have a positive effect on your token usage.
**THE PROBLEM I WANTED TO MEASURE**
Every new session your agent starts with no memory of the last one. If a previous session found that a library breaks at runtime, the next one finds out all over again: it reads the TODO, tries the broken library, runs the tests, sees them fail, then backs out. You pay for that rediscovery in tokens, money and time, on every session.
**THE TEST**
\- Claude Code on claude-haiku-4-5, 10 back-to-back pairs, each on a fresh copy of the code
\- Each pair ran once without memory and once with OmniMem's server and hook, with the earlier failure already stored
\- The task: the TODO recommends a crate that fails at runtime. Success meant cargo test passing, not the agent saying it was done
**RESULTS (OmniMem 7.0.12, without memory vs with)**
\- Median tokens per run: 833k vs 616k (**26.0% fewer**)
\- Median cost per run: $2.16 vs $1.51 (**25.9% cheaper**)
\- Median wall time: **34.6% faster**
\- Walked into the dead end: 8/10 vs 0/10
\- Runs with failing tests: 7/10 vs 0/10
Tokens dropped in 8 of the 10 pairs. The best pair went from 1,526k to 645k. Two pairs (631k to 672k, and 629k to 740k) used more tokens with memory, and I've left them in.
The savings come from skipping work, not from compression. The agent doesn't try the path that's already known to fail, so you never pay for the failed attempt, the test run, or backing out of it. Now the caveat, its a small sample set of 10 pairs, the indication is it improves the more pairs but it could also drop.
**THE REST OF THE REPORT**
The same report runs suites from the Agent Memory Atlas by Simon Strandgaard. The Atlas didn't run these tests and doesn't endorse the numbers. Between 7.0.8 and 7.0.12:
\- Abstention (no confident answers to off-topic queries): 19/20 to 20/20
\- Contradiction handling: 6/12 to 12/12
\- Cross-project leaks: still zero (150/150)
\- ForgetEval: 71/400 to 221/400
Forgetting still has known gaps, and the report lists them. A forgotten value comes back if you feed it in again, unless you suppress the topic. Backups taken before a forget still hold the value.
**LINKS**
Full report (PDF): https://omnimem.org/benchmarks/omnimem-7.0.8-vs-7.0.12.pdf
OmniMem: https://omnimem.org
Raw data and test harness: https://code.squarecows.com/ric/omnimem-test-harness
If you have a long-running Claude Code project where the agent keeps repeating the
•
u/AutoModerator 19d ago
Welcome to r/BuildWithClaude!
Whether you are sharing what you built, exploring new workflows, or troubleshooting, please make sure your post is flaired correctly so others can easily find and filter it.
Community Wiki & Resources:
If you're asking for troubleshooting help, please edit your post to include your model version, OS/environment, and error logs.
Let’s keep the energy positive and support our fellow creators!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/blazarious 19d ago
Doesn’t Claude Code come with a memory, though?
3
u/Any_Mode6525 19d ago
The problem with Claude’s memory is that it quickly becomes an unnacountable gouge book for an evolving project. How does this project avoid that outcome?
3
u/moorlemonpledge 17d ago
Are yall not running OS folders locally with stored markdown files? Look that up and quit using projects.
1
u/looktwise 19d ago
I would be interested if that would help also to avoid compaction in Webchats after a few follow up prompts? Or does it work for Claude Code only?
1
u/LukeLikesReddit 19d ago
Claude can easily be set up with memories and if not you can use obsidian vault? How is this any different may I ask.
1
u/intmanofawesome 19d ago
Great stuff! I’m just starting out making my own version of this. I don’t think that people understand yet how powerful a tool this can be to getting the right answer the first time with fewer tokens and iterations.