A Self-Tuning Memory Engine for AI Agents
An agent writes its own evals over a 52-document vault, diagnoses each miss, retunes strategy, weights and cues, and stores what it learned as memories. Keyword recall went from 59% to 88% in under a minute.
59% → 88%keyword recall, same model
- 59% to 88%
- keyword recall, 50 of 85 to 75 of 85 keywords
- 4 to 16
- queries out of 20 with every keyword found
- < 60 s
- agent time for the full loop
- 949
- memories: 465 sections, 484 extracted propositions
The research page treats agent memory as two problems. The store degrades as contradictions and stale facts accumulate, and retrieval stays rigid because every query is served with the same configuration.
Protocol
We indexed 52 markdown files from an enterprise legal department with GPT-4o-mini for proposition extraction and EmbeddingGemma-300M (768 dimensions, local ONNX) for embeddings. A Claude Opus 4.6 agent read the vault listing and wrote 20 evaluation queries: 10 similarity, 3 temporal, 2 causal, 3 analogical, 2 contradiction, with 85 expected keywords verified by hand against the vault. The baseline ran every query with similarity and k=5. The tuned run let the agent choose strategy, weights, k and cue wording per query, then store 5 generalized strategies as high-importance memories.
The strategies return different answers
One query, "Which vendors have similar compliance gaps?", run through three strategies:
| Strategy | Top result | Score |
|---|---|---|
| Similarity | Cloudvault Systems, Inc. is the vendor being assessed | 0.643 |
| Analogical (alpha=0.3) | Vendor risk assessments for Meridian and Praxis are incomplete | 0.483 |
| Temporal | All critical findings from Q4 2024 confirmed remediated | 0.913 |
Only the analogical result answers the cross-vendor question. Its structural similarity term weighs context-key overlap at 0.4, value-type match at 0.3, memory kind at 0.2 and entity pattern at 0.1.
Hebbian offset vectors
Each memory carries a second, associative embedding that starts as a copy of its content embedding. For each edge type we keep one offset vector, updated whenever an edge from i to j is created: offset = normalize(offset + 0.1 * (a_j - a_i)). Adding the offset to a seed's associative embedding gives a query for typical effects, subtracting it gives typical causes, and normalize(a_C + normalize(a_B - a_A)) answers A:B::C:?. We have not yet measured this mechanism in isolation, and it assumes relations are roughly linear in embedding space.
Decay check
For memories of equal age, decay scores were 0.500 at 0 accesses, 0.575 at 1, 0.650 at 3 and 0.694 at 5. Five recalls leave a memory 39% stronger than an untouched one, which matches the log2 term.
Limits
The 4 queries that still missed keywords involved dollar amounts and proper nouns in dense contract language that the embedding model did not surface at any setting. That is a floor set by embedding quality. The loop is as good as the agent running it, and the keywords were chosen by that agent. The ablation has one row: removing self-tuning costs 29 points. Blog posts on this vault quote 75% to 94% from a different run; the figures here are the ones with a documented protocol.
