TL;DR
Giving an AI assistant long-term memory requires tuning a complex "harness" of code, prompts, and configurations—a notoriously tedious manual process. HoMe automates this optimization by deploying AI developer agents that use Git-style memory versioning to pinpoint exactly when and how memories fail across hundreds of chat sessions, rewriting the underlying system architecture to fix them. In just a few hours and six evaluation rounds, HoMe discovers novel memory mechanisms that boost accuracy while slashing query-time token costs by roughly half.
What Problem Does This Paper Address?
For a long-running AI assistant to be genuinely useful, it needs a memory system that turns sprawling interaction histories into consistent, personalized behavior. Beneath the hood, these file-backed memory systems are governed by a harness: the executable code, prompts, and configuration thresholds that dictate how memories are written, updated, retrieved, and used to answer questions. Different tasks need vastly different harnesses—a medical bot must preserve symptom histories verbatim, while a scheduling bot should overwrite old meeting times rather than hoard them.
Tuning this harness is usually a slow, manual slog. While recent works have tried letting AI agents automatically edit memory harnesses, two massive hurdles get in the way over long horizons (thousands of messages):
- The needle-in-a-haystack diagnosis problem: When an assistant flubs a question after 200 chat sessions, why did it fail? Was the fact never written down in Session 12? Overwritten in Session 85? Missed during retrieval? Without knowing the root cause, automated optimizers take the path of least resistance—tweaking prompts and parameters while leaving broken underlying code untouched.
- Crushing evaluation costs: Testing a single harness tweak means re-reading hundreds of sessions to rebuild the memory from scratch, answering test queries, and grading them. Doing this repeatedly blows up compute budgets and wall-clock time.
Methods
HoMe (Harness Optimization of Memory Systems) treats automated system design like a disciplined software engineering team, coordinating Developer Agents, an Experiment Manager, and a sandboxed Evaluation Environment.
To make diagnosis accurate and evaluation affordable, HoMe introduces several clever mechanisms:
- Session-Level Memory Versioning & Diff Diagnosis: During memory construction, HoMe commits the memory files to a Git repository after every single session. When a query fails, a fleet of parallel "Case Study Agents" traces the failure backward. Using
git diffbetween session checkpoints, they see exactly when a fact was written, corrupted, or deleted without blowing up their context windows. A Diagnoser Agent aggregates these findings (map-reduce style) to spot recurring architectural bugs rather than isolated flukes, handing a clean report to the Optimizer Agent to edit the harness. - Git-Backed Search History: Every harness variant, along with its diagnosis and test results, is committed to a central repository. The Optimizer Agent can branch off earlier commits, refine current ones, or merge complementary fixes.
- Candidate Gating for Structural Exploration: Left unchecked, LLM optimizers gravitate toward cheap prompt edits. HoMe enforces a "gate" during the first half of its evaluation budget: it inspects code diffs and rejects prompt-only or superficial parameter tweaks, forcing the agent to explore genuine structural changes to the Python code first. Prompt tuning is only unlocked in the second half.
- Fast-Track Evaluations: HoMe cuts evaluation runtime via three levers: smoke tests on truncated sessions to catch syntax/runtime crashes early; adaptive sampling that prioritizes testing historically difficult or stale cases rather than the full dataset; and memory reuse, which skips rebuilding the memory files if a candidate harness only changed retrieval or answering logic.
Datasets
The authors do not introduce new benchmarks, evaluating instead on two existing large-scale, long-horizon conversational memory benchmarks:
- LongMemEval-S (LME): 500 single-query cases averaging 115K history tokens across six question types (split 50/50 for training and testing, using a cleaned ground-truth version).
- BEAM: Multi-query conversational histories spanning ten question types. The authors optimize harnesses on BEAM-100K (20 cases, 20 queries each, averaging 131K tokens) and test zero-shot scale generalization on BEAM-1M (35 cases averaging 1.04M tokens, peaking at 1.52M tokens).
Key Insights and Ideas
- Unconstrained agents are lazy coders: In baseline runs with MemPro (an existing evolutionary optimizer), zero proposed candidates modified executable code despite having full permission to do so—all edits were prompts or parameters. Explicit candidate gating and cross-case failure attribution are what actually push agents to invent new data structures and retrieval algorithms.
- Convergent evolution of memory principles: Running completely independently on LME and BEAM, HoMe invented two remarkably similar architectural upgrades on both datasets: compiling daily summaries into a compact, date-grouped directory for cross-session browsing, and enforcing per-file retrieval caps so long raw transcripts don't crowd out diverse memory notes.
- Smart compression beats bigger contexts: On BEAM, HoMe wrote code to score lines inside retrieved chunks by query keywords, replacing low-scoring lines with line-numbered placeholders (
03 [...]). The answering agent gets lean context upfront, while retaining the exact coordinates to fetch omitted lines on demand.
Key Results
Implemented atop the already strong open-source memory system ReMe, HoMe was given a strict budget of just 6 formal candidate evaluations per benchmark.
- Higher accuracy, far fewer tokens: On LongMemEval-S, HoMe boosted ReMe's score from 0.888 to 0.916 (+2.8 percentage points) while cutting query-time tokens by 59% (43.9K down to 17.9K). On BEAM-1M, scores jumped from 0.650 to 0.704 (+5.4 pp) with a 41% token reduction (101.8K to 60.4K)—proving that harnesses optimized on 131K-token chats generalize smoothly to histories 8× longer.
- Outperforming automated baselines: Compared to MemPro, HoMe scored 10.4 pp higher on LME (using 81.5% fewer query tokens) and 1.1 pp higher on BEAM (7.6% fewer tokens), while consuming 44.1% fewer total optimization tokens. Harnesses discovered by HoMe also transferred better across benchmarks without re-tuning.
- Massive evaluation speedups: Combining sandbox parallelism, adaptive sampling, and memory reuse slashed the time for a single formal evaluation from 153.5 hours to 2 minutes on LME, and from 14.4 hours to 8 minutes on BEAM. Strong Pareto-optimal harnesses emerged within 2 to 4 iterations (about 6.3 hours wall-clock on BEAM).
Limitations and Future Work
- Category trade-offs: While overall accuracy rose, HoMe's optimized harnesses showed score declines relative to baseline ReMe on specific question types—namely LongMemEval-S multi-session questions and BEAM knowledge-update and information-extraction tasks.
- Diminishing returns and overfitting risk: On BEAM, iterations 5 and 6 failed to push the Pareto frontier forward. The authors note that as code edits accumulate, the optimizer may become more sensitive to random noise in the adaptively sampled subsets and more prone to overfitting.
- Non-comparable intermediate scores: Because adaptive sampling shifts focus toward hard failures each round, raw iteration scores aren't directly comparable, requiring the LLM Optimizer Agent to make nuanced judgment calls using shared-query comparison tables at the end of the budget.
Summary updated