CompactionMemoryAdvisor, MemoryStore) shipped in 0.1.0 and is unchanged; 0.2.0 aligned on the Jackson 2.21.2 BOM.
Overview
Agent Memory gives AI agents the ability to manage conversational context intelligently. Without memory management, every prior tool result is re-sent every turn — on long tasks, context fills with stale noise, costs climb, and the model loses focus. In production: 18M input tokens for a single code-coverage task. With compaction: 854K tokens. 21x reduction, same quality. The library starts with a proven context compaction strategy and progressively adds structured retrieval, reflection, and autonomous memory management — eventually reaching MemGPT-level capabilities. Each tier is independently useful. Agent Memory ships as a Spring AIBaseAdvisor — plug it into any ChatClient pipeline with one line:
budget × ratio, compaction summarizes them via a cheap model and replaces them with dense summaries.
How Compaction Works
When accumulated context exceeds a token budget, older entries are summarized by a cheap model (e.g., Haiku) and replaced with a compact summary. The agent continues with dense, relevant context instead of an ever-growing prompt. Two parameters control it:Benchmark Data
Real LLM benchmarks against Anthropic Haiku 4.5 on a 12-story e-commerce platform PRD:
Token growth without compaction is linear and unbounded (~800 tokens/story, reaching 9,000+ by story 12). With compaction it plateaus around 4,600 tokens after the first compaction cycle.
Budget Sensitivity
The memory budget is the critical tuning parameter:
At 2,048 tokens, compaction destroys critical details — table names, endpoint signatures, auth token formats — that later tasks depend on. At 4,096, it preserves what matters and discards what doesn’t.
Production Validation
In a code-coverage experiment with Loopy:
Compaction does not change answer quality. It determines whether the run finishes within budget.
Roadmap
Modules
Quick Links
GitHub
Source code (0.3.0 on Maven Central)