🤔 Why I built this
I’ve been using AI agents (specifically DeepSeek Harness) for a while now, and I kept running into the same wall: Amnesia.
The agent would fix a tricky bug, I’d accept the changes, and then 20 minutes later, it would make the exact same mistake again because it forgot how it fixed it the first time.
I looked at existing memory solutions (Mem0, Letta, etc.), but they all rely on calling an LLM to summarize the session. I didn't like that because:
It costs money/tokens. Every write operation is an API call.
It’s slow. Waiting for a summary blocks the workflow.
It’s fuzzy. LLMs sometimes "hallucinate" details that weren't in the code.
I thought: "Can't I just parse the logs and git history deterministically? Like, actual code, not AI guessing?"
So I hacked together tmem.
🛠️ What is it?
tmem (Trace Memory) is a tiny Python tool that acts as a "flight recorder" for your agent.
Instead of asking an LLM to summarize what happened, it looks at the raw session.v4.jsonl logs and your git diff. It uses simple heuristics—like Python AST parsing and exit codes—to figure out what actually changed and why.
The philosophy:
Zero LLM calls for memory extraction.
Zero external dependencies (just standard Python libs).
Deterministic. If the code changed, it remembers. No vibes-based summarization.
📊 Does it work?
I’ve been testing it on my own repos for the past few weeks. It’s not perfect, but the results are surprisingly decent.
In a quick A/B test on 50 tasks, the agent with tmem had a ~22% higher success rate than the baseline. The best part? It reduced the interaction steps by about 37% because the agent stopped repeating failed approaches.
It works by injecting context only when relevant (e.g., when you touch a file that was previously modified in a specific way), rather than flooding the context window.
⚠️ The "It's Early" Disclaimer
I’m sharing this as a "works for me" experiment, not a polished product.
Known limitations:
It’s hardcoded for DSH. I haven't written adapters for Claude Code or Cursor yet (PRs welcome!).
Python-centric. The AST parsing is solid for Python, but for JS/Go, it mostly just tracks file changes.
Heuristics are brittle. If you do something super complex with metaprogramming, it might miss the context.
đź’» Give it a spin
If you’re a DSH user and want to try it out, it’s super lightweight:
bash
git clone https://github.com/kentzjh-cmd/tmem.git
cd tmem
pip install -e .
Then just enable the plugin. It runs in the background and starts building a local memory index.
đź’¬ Thoughts?
I’m really curious if anyone else is exploring deterministic memory vs. LLM-based memory. Is the "zero-token" approach viable for larger codebases, or will I hit a wall eventually?
Let me know if you break it (or if it actually helps!).
Repo: github.com/kentzjh-cmd/tmem
Top comments (0)