The memory graph: links between facts decide what the agent reads
Saved memories in MendCode can be linked as related, conflicting, supporting or superseding. The links change which memories reach the prompt, and the Graph tab shows where the knowledge is thin.

A list of saved memories answers “what do we know?”. It does not answer “which of these replaced that one?” or “which two cannot both be true?”. MendCode keeps those answers as links between saved memories, and uses them every time it chooses what the agent reads.
Why links
Memory goes stale in two ways: a newer fact replaces an older one, or two facts contradict each other and nobody notices. A flat list hides both. With links, the newer fact supersedes the older one and the older one drops in the ranking; a conflict turns the graph’s status red until someone edits or archives one side.
Four kinds of link
Links
| Kind | Direction | Meaning |
|---|---|---|
| related | both ways | on the same subject |
| conflicts | both ways | cannot both be true; one should be edited or archived |
| supports | from → to | the first backs up the second |
| supersedes | from → to | the first replaces the second |
Rules
- Only saved memories can be linked. Pending and archived ones cannot.
- A memory has at most 16 links, and a pair has at most one: linking it again replaces the kind.
- Deleting a memory removes its links. Archiving keeps them, but archived memories leave the graph.
- The graph follows profiles: the directory’s project memories and its profile’s user memories are nodes; another profile’s are not.
How links change the prompt
Before each model call MendCode ranks the memories the session may see and injects them as the <mendcode_memory> block, within a retrieval budget of 6,000 characters by default.
What fills the block
Pinned memories, always, newest first. At most 20 per profile, directory or session.
Memories that match the prompt, or are linked to one that does, best first.
A small share of the rest, at most a quarter of the budget (1,500 characters), so standing rules still surface.
A memory’s score is its match, its recency (half-life of 30 days), its links to matches and a small lift for preferences, constraints and security, minus a penalty when another saved memory supersedes it. A memory already shown in the session gets a lift too, so the block only changes when the ranking clearly does, which keeps the provider’s prompt cache useful.
Graph health
The first row of the Graph tab
| State | Means |
|---|---|
| empty | nothing is saved |
| disconnected | nothing is linked |
| partial | some memories have no links |
| connected | every memory has at least one link |
The row also counts isolated memories and conflicts. A conflict turns it red.
The Graph tab
/memory has nine tabs; the fifth is Graph. Arrows or hjkl move to the nearest memory in that direction, enter or f switches between the view around one memory and the whole graph, m marks a memory, c links the marked one to the selected one and x unlinks them. The view shows up to 200 memories, the most linked first.
The agent’s tool
The agent reads and edits the same graph with the memory_graph tool: overview, search, upsert_fact, link and validate. An upsert keeps the memory’s id and links when its text changes. When the prompt block leaves memories out, it says how many and points the agent to memory_graph search.