Selective Forgetting: A Graph-Based Memory Framework for Long-Term LLM Agents
Organizations: Department of Computer Science Toronto Metropolitan University Toronto, Ontario, Canada · The Creative School Toronto Metropolitan University Toronto, Ontario, Canada · Flybits, Creative AI Hub Toronto, Ontario, Canada
Abstract
Knowledge graphs have been proposed as a structured alternative to flat retrieval-augmented generation for long-term agent memory, on the assumption that representing conversations as entities and relations improves recall. We evaluate that assumption directly. Our framework extracts each conversational turn into typed nodes and attributed edges, answers questions from a two-hop subgraph, and periodically prunes nodes that score low on a weighted combination of recency, access frequency, degree centrality, and age. On LongMemEval, the graph does not outperform a flat vector baseline at a matched candidate-generation budget of five retrieval roots: token F1 is against , and a paired bootstrap over 500 questions gives (95% CI ). The gap is widest on questions that require recalling a specific prior assistant turn, where judged correctness falls from to , suggesting that decomposing a turn into entities discards the surface form these questions depend on. The forgetting module is more successful. Applied once to a persistent 27{,}021-node graph, it removes 9.8% of nodes and 9.5% of stored bytes; token F1 is unchanged (, 95% CI ) and judged correctness falls by points, with the 95% interval bounding any loss at points (). Because our extractor is a single small model evaluated on one benchmark, these results characterise this extraction-based pipeline rather than graph-structured memory in general. Code: https://github.com/skhanzad/Selective-Amnesia
Figures & tables
| Graph RAG (Ours) | Baseline RAG | |||||||
|---|---|---|---|---|---|---|---|---|
| Type | n | P | F1 | J | n | P | F1 | J |
| Single (user) | 70 | 0.743 | 0.737 | 0.771 | 70 | 0.823 | 0.819 | 0.929 |
| Single (asst.) | 56 | 0.680 | 0.575 | 0.607 | 56 | 0.916 | 0.774 | 0.911 |
| Single (pref.) | 30 | 0.312 | 0.083 | 0.233 | 30 | 0.274 | 0.114 | 0.367 |
| Know.-update | 78 | 0.507 | 0.456 | 0.513 | 78 | 0.553 | 0.511 | 0.590 |
| Multi-session | 133 | 0.384 | 0.326 | 0.398 | 133 | 0.381 | 0.342 | 0.436 |
| Variant | Nodes | Edges | Size | F1 | Judge |
|---|---|---|---|---|---|
| No-forgetting | 27,021 | 46,538 | 440.6 MB | 0.292 | 0.300 |
| Forgetting | 24,368 | 43,978 | 398.6 MB | 0.293 | 0.284 |
| Change | 9.8% | 5.5% | 9.5% | 0.001 | 0.016 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Parameter | Value | Basis |
|---|---|---|
| De-duplication cosine threshold | 0.92 | E |
| Retrieval cosine floor | 0.75 | E |
| Retrieval roots (top- ) | 5 | C |
| Subgraph expansion depth | 2 hops | B |
| Subgraph node cap | 15 | B |
| Forgetting interval | 400 turns | B |
| Stage | Cost | Note |
|---|---|---|
| Embed extracted entities | ||
| Title de-duplication | per entity | hash index |
| Embedding de-duplication | linear scan | |
| Graph write | indexed updates | |
| Candidate retrieval | linear scan | |
| Subgraph traversal | adjacency build |
| Condition | F1 | Precision | Recall | Judge acc. |
|---|---|---|---|---|
| Baseline RAG (per-question, Experiment 1 control) | ||||
| Graph RAG (per-question, Experiment 1 treatment) | ||||
| Persistent graph, no forgetting (Experiment 2 control) | ||||
| Persistent graph, with forgetting (Experiment 2 treatment) |
| Condition | F1 | Precision | Recall | Judge acc. |
|---|---|---|---|---|
| Baseline RAG (per-question, Experiment 1 control) | (Wilson: ) | |||
| Graph RAG (per-question, Experiment 1 treatment) | (Wilson: ) | |||
| Persistent graph, no forgetting (Experiment 2 control) | (Wilson: ) | |||
| Persistent graph, with forgetting (Experiment 2 treatment) | (Wilson: ) |
| Comparison | F1 | Precision | Recall | Judge acc. |
|---|---|---|---|---|
| Experiment 1: Graph RAG vs Baseline RAG | ∗ | ∗ | ∗ | |
| Experiment 2: Forgetting vs No forgetting |
Graph-Based Agent Memory
Graph-based agent memory organizes an agent’s experiences, facts, and procedures as linked structures for persistent, evidence-aware retrieval and reuse.
See all 133 papers