Change one fact. GEM fixes what depended on it.
Agent memory that keeps track of which facts were worked out from which. When one changes, GEM rewrites what it can, flags what it can't, and leaves the rest alone.
01
Memories depend on other memories.
Your commute was worked out from where you live. Your alarm, from the commute. The coffee maker, from the alarm. GEM records each of these dependencies as it stores a fact, whether you give it or GEM infers it.
02
Then one changes.
“I moved to Mumbai.” Before storing it, GEM compares it with similar facts. One conflicts directly, where you live, and is updated.
03
Ordinary memory stops there.
Same write, flat memory. The direct conflict is fixed. The four facts built on it are still served as true, and nothing marks them wrong. This is what your agent reads back:
04
GEM follows the links.
The change runs down every derived-from link, and each fact is checked against this change. Commute, alarm, coffee maker and rent go stale. Your timezone is unaffected: Mumbai is still IST, so the cascade stops there.
05
When the new value follows, it's rewritten.
A different memory: your manager changes from Alice to Bob. Here every new value can be worked out from the change, so each routine built on it is rewritten. Bob gets the weekly report, approves time off, and writes your review.
06
When it doesn't, it's flagged, not guessed.
Nothing in “I moved to Mumbai” says how long the new commute is, so GEM doesn't invent one. The fact is marked stale and handed to your agent, which asks you:
Your answer replaces the stale fact and takes over its links, so the next change still reaches it. If the old value still holds, the agent confirms it instead.
07
Most decisions are cheap.
Each hop is one batched question to a small decision model that answers with probabilities: the rings. The LLM only writes corrections and settles doubts. Stopping the cascade takes 90% confidence; anything doubtful goes to the LLM.
08
A write costs what it touches.
Here is all of memory: six groups, 33 facts. Six changes arrive, one at a time. Each one lights up only its own group: GEM checks a few similar facts, then follows the links from the one that changed. Everything else stays dark.
Make a change.
Six recorded runs, from coding agents to planning. Pick one, then switch to flat memory to see what it leaves behind.
Measured, not asserted.
Each number comes from a run file in the repository. Re-run the script and you get the file.
facts handled correctly across 12 cross-domain scenarios: medical, legal, finance, six-step chains.
eval_diverse_groq20b_jev.txtrepeat runs at 100% on 19 scenarios held out from tuning; none flipped between runs. LLM-only: 99.0%.
determinism_jev_groq120b.txtfacts right out of 117, GEM against flat memory on the same 37 propagation scenarios.
propagation_eval_strat_clean.txtLLM calls per write: about 25 for 19 writes, with the decision layer answering first.
determinism_jev_groq120b_calls.txtFlat memory is the same engine with the cascade switched off. Protocol
Add it to your agent.
Run GEM as an MCP server for Claude Code, Claude Desktop, Cursor and other clients, or import it as a Python library.
git clone https://github.com/rdarshan10/GEM && cd GEM
pip install -e ".[mcp,embeddings]"
cp .env.example .env # pick your model here
claude mcp add gem -- python -m gem.mcp_serverfrom gem import Memory
m = Memory()
home = m.add("I live in Bangalore").id
m.add("My commute is 45 minutes", derived_from=[home])
r = m.add("I moved to Mumbai")
r.invalidated # [My commute is 45 minutes]- add_memorySave, forget or confirm a fact. Returns what it updated and what it made stale, several links away. An answer to a stale fact replaces it.
- search_memoryValid matches, with outdated ones in a separate list.
- get_profileA summary built only from facts that are still true.
- get_staleFacts to reconfirm with the user.
- whyThe facts a fact was derived from.
- list_memoriesEverything in a memory space.
Bring your own model. Ollama and Groq are built in; any other provider is one small class in gem/llm.py.
Honest about the edges.
What GEM isn't for, and what it can't do yet.
Built for chains
If your facts are independent, such as preferences and profile fields, flat memory is as accurate and cheaper.
Inferred links miss some
When you don't pass derived_from, GEM infers links with about 85–88% recall in our tests. Pin the ones you can't afford to miss.
Stale facts wait for an answer
When a new value can't be worked out, GEM flags the fact instead of guessing. Someone still has to answer.
A research build
Measured on hand-built scenarios and benchmarks, not yet run in production. Licensed PolyForm Noncommercial; the API may change.