Command Palette
Search for a command to run...
Agentic Context Management: Solving Agent Memory and Cost by Treating Them as Lifecycle and Architecture Problems
Agentic Context Management: Solving Agent Memory and Cost by Treating Them as Lifecycle and Architecture Problems
Gaurav Dadhich
الملخص
Production AI agents’ failures are less often because of an inability to reason well and more often because they cannot manage what is in their reasoning context; across a large number of things they must hold in context: conversation histories, large prompts, large tool definitions and ballooning tool outputs. They drown in their own accumulating history while paying for a token cost that grows with every turn, resulting in missing recalls both within the same conversation as well as across conversations. The incumbent response treats this as a storage and retrieval problem. We argue that this framing is too narrow. We propose that actively managing what an agent holds in mind is a lifecycle, not merely a store: it spans deciding what to remember, extracting and structuring it, choosing the right store for the right data-type, carving optimal redundancies, conscious consolidation, forgetting stale information while maintaining provenance, deciding what is relevant for the current turn, anticipating what will be needed next and compacting context to fit a budget without losing what matters, without compromising on recall and so on. In serious production agents, this operates not only over a single user but across an organizational scope hierarchy. We prefer naming this discipline Agentic Context Management (ACM) (as have some others in the past) and decompose it into five primitives: architecting, ingesting, scoping, anticipating, and compacting & consolidation. We then make the economic case for why a managed lifecycle is not a luxury: naïve context accumulation grows token cost quadratically in conversation length, crude summarization buys linear cost at the price of an accuracy clif and only validated compaction achieves linear cost with preserved fidelity. We describe a reference implementation, Maximem Synap, that realizes these five primitives as a multi-tenant service and reports 92% on LongMemEval and 93.2% on LoCoMo under the configuration detailed in Section 6. Lastly, we close with the dimensions existing benchmarks do not yet capture viz. latency, token eficiency and context-rot resistance and the open frontier of decision-level and organization-level context that the category points toward; but continue to determine stability and usability of an agent’s utility in serious setups.
One-sentence Summary
Gaurav Dadhich introduces Agentic Context Management (ACM), reframing agent memory as a lifecycle problem with five primitives—architecting, ingesting, scoping, anticipating, and compacting & consolidation—that economically reduce token cost from quadratic to linear while preserving fidelity, and a reference implementation, Maximem Synap, achieves 92% on LongMemEval and 93.2% on LoCoMo.
Key Contributions
- The paper introduces Agentic Context Management (ACM) as a lifecycle decomposed into five primitives (architecting, ingesting, scoping, anticipating, and compacting and consolidation), shifting the framing from static storage to active, multi-turn context orchestration.
- An economic analysis shows that naive context accumulation leads to quadratic token cost growth, crude summarization yields linear cost but suffers an accuracy cliff, and only validated compaction achieves linear cost with preserved fidelity, establishing the lifecycle as a practical necessity.
- A reference multi-tenant service, Maximem Synap, implements the five ACM primitives and reports 92% on LongMemEval and 93.2% on LoCoMo, while also identifying benchmarking gaps in latency, token efficiency, and context-rot resistance.
Introduction
The authors observe that production AI agents often stumble not from reasoning failures but from undisciplined context management: agents forget earlier instructions, hallucinate from overloaded windows, and incur ballooning costs when entire histories are blindly appended. The dominant framing treats this as a “memory” problem that merely stores and retrieves facts, but it ignores essential lifecycle decisions—what to retain, how to structure it, which fraction belongs in the current turn, what to anticipate next, and how to safely compact context under a budget. The authors reframe the challenge as Agentic Context Management, a system organized around five primitives—architecting, ingesting, scoping, anticipating, and compacting/consolidation—that operate coherently across user, customer, and organizational scopes. They demonstrate that naive full-append context leads to O(n2) token costs, while managed compaction reaches the efficient frontier of linear cost with verified fidelity, and they supply a reference implementation (Maximem Synap) that materializes the complete lifecycle.
Method
The authors introduce Maximem Synap, a multi-tenant hosted context-management platform that realizes the five primitives of agentic context management as a coherent lifecycle rather than as disconnected tools. The system is designed to address the failures of naive store-and-retrieve approaches: cost explosion from unbounded contexts, accuracy collapse from unchecked compaction, and reasoning insufficiency from retrieval that scores hits but misses the bridge context needed for agents to produce correct answers.
At the heart of Maximem Synap lies an autonomous architecting step. When an agent is connected, the system synthesizes a bespoke memory architecture from the customer’s description of the agent’s purpose and reference material. This design, generated via multi-agent LLM reasoning and validation, determines which memory categories to capture (facts, preferences, episodes, emotions, temporal events, etc.), how they should be extracted, stored, retrieved, and compacted, and what entities and relationships matter. This architecture governs every downstream primitive, making the coupling among primitives concrete: a support agent and a coding agent receive different category schemas, retention policies, and compaction rules, all embodied in a single generated artifact.
Ingestion is an asynchronous, queue-backed pipeline. A document or conversation turn is submitted through an async-first SDK that returns an ingestion identifier immediately without blocking the calling application. In the background, the pipeline qualifies content, extracts memory categories as dictated by the agent’s architecture, and resolves entities. Entity resolution runs a confidence-ordered cascade of matching strategies—from exact identifiers through lexical, semantic, and contextual signals—linking surface mentions to canonical identities at the customer scope. Public entities are validated against a global knowledge layer; new ones are registered. The extraction and resolution results are persisted across a polyglot stack: a relational store as source of truth, a vector store for embedding-based search, a graph store for entity–relationship traversal, an object store for original content, and specialized stores for time-series telemetry and queuing/caching. The immediate consistency trade-off is deliberate: read-after-write within a session is satisfied by carrying recent turns verbatim in memory, so the agent operates on the latest information while durable, structured availability is deferred without blocking.
Retrieval is a scope-aware, budget-conscious pipeline that resolves the organizational hierarchy narrowest-first: user, then customer, then client, under strict isolation enforced at both storage and query layers. It assembles provenance-tagged, ranked memory items fitted to a token budget. Two retrieval modes are offered: a low-latency path and a higher-accuracy path that adds query decomposition and LLM reranking. Crucially, the system combines vector similarity with vector-guided multi-hop traversal of the knowledge graph. Semantic similarity informs where to enter the graph and which relationships to follow, surfacing related memories that pure vector search would miss—directly addressing the bridge-document problem that causes reasoning insufficiency.
Anticipating is treated as a retrieval primitive distinct from explicit query-time retrieval. Maximem Synap implements an anticipatory path that predicts from an agent’s evolving behavior the context it will likely need before an explicit request arrives. This prepared context is available as a cache read when needed, moving retrieval off the agent’s critical path and reducing latency. The prediction mechanism is proprietary; the authors report a sustained hit-rate above 60% in production, with the value being latency reduction rather than deduplication.
Compacting and consolidation are designed as verified operations. For long conversations, Maximem Synap compresses the context and then validates the result against the original: it tests whether key information remains recoverable and emits an explicit validation score together with a compression ratio. If the score falls below a threshold, compaction is automatically retried with less aggressive compression. This category-aware compaction—what must be preserved verbatim versus what may be abstracted is determined by the agent’s generated architecture—prevents the catastrophic accuracy loss that unvalidated summarization causes. To keep validation overhead linear, compaction operates periodically on the already-compacted context plus recent turns, not on the full transcript. The total token cost over N turns follows N⋅W⋅(1+c/p), where W is the token budget, p the compaction frequency, and c a fixed factor; this is a linear cost raised by a constant factor, providing dramatic savings compared to the quadratic blow-up of appending full history.
The platform exposes a simple three-call integration pattern per model invocation: scoped retrieval of past context, validated compaction of the current conversation, and non-blocking ingestion of the new turn. The application code never touches schema design, embedding models, index management, or isolation logic; those are handled entirely by the lifecycle’s primitives and the generated architecture. The design choices—synthesized architecture, verified compaction, asynchronous ingestion, first-class scoping with enforced isolation, hybrid semantic-relational retrieval, and anticipatory latency design—directly address the production failure modes observed in store-and-retrieve systems and implement the lifecycle that the paper argues is necessary for agentic memory at scale.
Experiment
The evaluation uses LongMemEval and LoCoMo to validate conversational memory, where multi-session reasoning is hardest, reflecting a broader reasoning-sufficiency gap: standard retrieval benchmarks measure hits but not whether all necessary context appears, with vector and keyword search winning in complementary regimes. Despite this gap, the system achieves strong results driven by its context layer rather than a large answer model, underscoring the need for hybrid retrieval and new evaluations that directly score sufficiency and production dimensions.
Production memory systems fail in distinct modes that correspond to missing context-management primitives. Ingesting and architecting gaps cause junk accumulation, lost detail, and identity fragmentation; scoping deficits lead to scope bleeding and cross-session amnesia; unvalidated compaction creates an accuracy cliff that can drop performance below a no-context baseline. Junk accumulation, lost detail, and identity fragmentation all stem from missing ingestion and architecting primitives, including a real-world 99.6% junk rate when storing raw signals without extraction. Scope bleeding and cross-session amnesia arise without scoping, while unvalidated compaction produces an accuracy cliff where performance drops below a no-context baseline after aggressive compression.
Three context-management strategies are compared: full-append, crude summarization, and validated compaction. Full-append incurs quadratic token cost and suffers from context degradation like the lost-in-the-middle effect, while crude summarization has linear cost but risks an accuracy cliff from discarding relevant detail. Validated compaction achieves linear cost with preserved and checked fidelity, as demonstrated by Maximem Synap's 92.0% LongMemEval score, avoiding both failure modes. Full-append has O(n²) token cost and eventually fails through context rot, such as the lost-in-the-middle phenomenon. Crude summarization cuts cost to O(n) but is lossy and unvalidated, creating an accuracy cliff when the summarizer discards what matters downstream. Validated compaction maintains O(n) token cost while preserving and checking needed information, making it the target with no inherent failure mode. An implementation of validated compaction reached 92.0% on LongMemEval, confirming that preserved and checked fidelity prevents the accuracy cliff seen with crude summarization.
Maximem Synap achieved 92.0% overall accuracy on the LongMemEval conversational memory benchmark and 93.2% on LoCoMo categories 1–4, both evaluated with a transparent configuration and a small answer model (gpt-5-mini). Multi-session reasoning proved the most challenging LongMemEval category (75.2%), consistent with a broader pattern across systems. The consistent use of a smaller answer model suggests that performance gains arise from the memory and context retrieval layer. The system reached 92.0% on LongMemEval (all 500 questions) and 93.2% on LoCoMo categories 1–4, both using gpt-5-mini as the answer and judge model. Multi-session reasoning, which requires joining information from separate conversations, was the weakest category at 75.2%, underscoring a well-known difficulty across published systems. LoCoMo's adversarial unanswerable category (category 5) was excluded following the official convention, preventing an artificial score swing and maintaining comparability with prior work. The evaluation harness (maximem-ai/memory_and_context_eval_harness) and methodology are publicly documented, and per-run artifacts are available on request to support reproducibility. Using a smaller answer model than many competitor configurations indicates that the performance advantage originates from the context pipeline rather than from the scale of the answering model.
Self-reported LongMemEval scores show Maximem Synap at 92.0% with a smaller answer model than competing configurations, while other systems exhibit sensitivity to answer model swaps. Because each row uses a different methodology, judge, and setup, the numbers are not directly comparable; multi-session reasoning remains the hardest category for all documented systems. Maximem Synap achieves 92.0% on LongMemEval using gpt-5-mini, a smaller answer model than those in the strongest competitor configurations, indicating that the gain comes from the context layer rather than the answer model. SuperMemory's LongMemEval results span 81.6% to 85.2% across answer models alone, demonstrating how sensitive memory benchmarks are to evaluation choices. Multi-session reasoning is the weakest category for Maximem Synap at 75.2% and is described as the hardest published category for every known system. The the table a landscape of each vendor's own best self-reported figure under differing methodologies and cannot be treated as a head-to-head comparison.
Across the surveyed memory systems, no system publicly declares full primary coverage of all five primitives. Ingesting and Scoping appear most often as either primary or partial capabilities, while Compacting & Consolidation is a primary focus for only one system. Architecting is a primary concern for some systems and absent from others, revealing divergent design priorities. MemGPT/Letta is the only system that lists Compacting & Consolidation as a primary focus. Ingesting is supported at least partially by every system except ACE/Dynamic Cheatsheet, making it the most widespread primitive. Architecting is a primary focus for MIRIX, Mem0, and SuperMemory, but it is not a stated focus for MemGPT/Letta, Zep/Graphiti, or Cognee. Scoping is partially or fully covered by six of the seven systems, with Zep/Graphiti and MemGPT/Letta giving it primary emphasis. Anticipating is never listed as a primary focus; it appears only as a partial or optional capability in four systems.
These experiments evaluate failure modes and strategies in production memory systems, showing that missing ingestion and architecting primitives lead to junk accumulation and identity fragmentation, while scoping deficits cause scope bleeding and amnesia. A comparison of full-append, crude summarization, and validated compaction finds that only validated compaction maintains linear cost and accuracy, as demonstrated by Maximem Synap's 92.0% on LongMemEval with a small answer model. Multi-session reasoning remains the hardest category across systems, and a survey of seven systems reveals no one covers all five primitives, with compacting and anticipating being the least addressed.