What Is Agentic Context Management? Definition, the Five Primitives, and How Agents Manage Their Own Context

Context EngineeringAI Agent MemoryMaximem Team16 May 202616 min read
What Is Agentic Context Management? Definition, the Five Primitives, and How Agents Manage Their Own Context
On this page
  1. The term names different layers of the same stack, depending on who uses it
  2. It sits above context engineering, RAG, memory and ACE
  3. Agentic context management has five primitives
  4. Inside a run, agents compact, offload, recall and isolate
  5. Agents can manage their own context, but mostly only when trained to
  6. Unmanaged context grows cost quadratically and costs accuracy
  7. Across sessions and across agents: what outlives the run
  8. Eight production failures it prevents
  9. Context management is working when success rises and peak tokens fall
  10. Where to start, and when you do not need it
  11. Where Maximem Synap fits
  12. Frequently asked questions

Published 16 May 2026. Updated 17 November 2026 with the two July 2026 papers that define the term, the techniques agents use inside a run, and what the evidence shows.

Agentic context management is the discipline of deciding what an AI agent should hold in its context window, when, for how long and at what cost, across the whole life of that context: from the moment information is captured to the moment it is retired. That is the definition in our paper, Agentic Context Management: Solving Agent Memory and Cost by Treating Them as Lifecycle and Architecture Problems (arXiv, 23 July 2026), and it covers two jobs that are usually treated separately: keeping the working context of one long run lean, and carrying the right facts into the next run without carrying everything.

Why the term matters: the default behaviour of an agent is expensive. Every LLM call is stateless, so a hand-rolled agent re-sends its whole growing history on every turn, and the input tokens it pays for across a conversation grow with the square of the conversation's length. Holding each turn to a fixed budget makes that growth linear. With 500 tokens added per turn and a 4,000-token budget, the paper works the gap out at roughly 6x by turn 100 and roughly 13x by turn 200, and the gap keeps widening the longer the agent runs.

Three days after our paper, a team at Carnegie Mellon (with Meta in an advisory role) published ACM: Agentic Context Management for Long Horizon Tasks (arXiv, 26 July 2026), which uses the same name for a narrower and complementary idea: the model itself decides when to compress its context, writes the raw messages to disk, and queries them later. Both readings are correct, and an agent that runs in production needs both.

The term names different layers of the same stack, depending on who uses it

People use the phrase in three ways today, and most confusion about it comes from people talking about different layers of the same stack.

MeaningWho decides what is in contextScopeWhere it comes from
The agent edits its own working context with toolsThe model, during the runOne task or episodeLi et al., CMU, July 2026
A lifecycle discipline: architect, ingest, scope, anticipate, compact and consolidateA system outside the model, before and after each callMany sessions, users and organisationsDadhich, Maximem, July 2026
A folder of markdown files plus rules that inject the right file into the promptThe developer, through declarative rulesInstructions and reference knowledgeMindStudio, June 2026

"Agentic" points at the same thing in all three: context is managed continuously while the agent works, instead of being assembled once by a developer and frozen into a prompt. What differs is who holds the pen. In the CMU framing the model does; in ours a lifecycle system does, with the model as one participant; in the file-based framing the developer does, ahead of time.

It sits above context engineering, RAG, memory and ACE

Anthropic defines context engineering as "the set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference", and calls it "the natural progression of prompt engineering", which is about how to write and organise the instructions themselves. Agentic context management sits one level above context engineering: context engineering asks which tokens belong in this call, and agentic context management asks who answers that question at run time, how the answer changes as the task moves, and what happens to everything that did not make the cut.

TermWhat it decidesWhat it leaves out
Prompt engineeringHow the instructions are worded and organisedEverything that is not an instruction
Context engineeringWhich tokens go into a given callWho makes that choice over a long run, and what persists afterwards
RAGWhich stored passages to fetch for a queryWhat gets stored, what gets forgotten, whose data it is
Agent memoryWhich facts about a person or the world persist across sessionsKeeping the working context of one long run lean
ACE, Agentic Context EngineeringHow a reusable playbook of strategies evolves through generation, reflection and curationManaging the context inside a single trajectory
Agentic context managementAll of the above as one lifecycle, with the decision made continuouslyNothing by design, which is why it is an architecture question and not a feature

ACE is the name most often mixed up with agentic context management. ACE, from Zhang et al., treats contexts as "evolving playbooks" and updates it in small increments so that details are not lost; the CMU paper uses ACE as a baseline and describes it as a memory agent that "accumulates experiences from previous rollouts but does not dynamically manage its intra-trajectory context". One improves what the agent carries between tasks, the other manages what it holds during one.

Our paper draws the line between memory and context management this way: "a system that addresses one primitive well is a memory tool. A system that addresses all five coherently, across scopes, is a context-management platform."

Agentic context management has five primitives

Our paper breaks agentic context management into five primitives, each of which exists because its absence produces a named failure in production.

  1. Architecting. Before anything is stored, something has to decide the shape of memory for this agent: which categories of information matter, how they are extracted, where they live, how long they persist, and how they are retrieved and compacted. A support agent and a coding agent need different answers, which is why a fixed universal schema fails one of them.
  2. Ingesting. Raw signals (conversation turns, documents, tool calls and their responses) have to become structured, retrievable memory. Retrieval quality is capped by ingestion quality: a system that stored "the user mentioned a pricing plan" can never later retrieve "the user upgraded from Starter to Pro on April 3".
  3. Scoping. At ingestion and at retrieval, the system decides which slice of everything it knows applies, across a hierarchy of user, customer organisation and the platform operator, resolved narrowest-first under strict isolation so that one user's context never appears in another's session.
  4. Anticipating. Agents do not know what they do not know, so they rarely ask for it. Anticipation prepares the context the agent is likely to need next, before the request arrives, which also takes retrieval off the critical path of each turn.
  5. Compacting and consolidation. When relevant context exceeds what the model can use well, the system reduces it without discarding what will be needed later, and the reduction has to be verifiable, because a compaction that silently drops a fact produces confident wrong answers.

These primitives are coupled. Whatever architecture is chosen in the first step changes what the other four should do, and that coupling is the argument for treating context as one system rather than assembling five unrelated tools.

Inside a run, agents compact, offload, recall and isolate

Within a single long task, the techniques have converged. Anthropic names three for long-horizon work: compaction (summarising a context that is nearing the window limit and continuing from the summary), structured note-taking (the agent writes notes that persist outside the window and reloads them later) and sub-agent architectures (focused subtasks handled by agents with clean context windows).

CMU's paper reduces the in-run problem to two tools. manage_context compresses earlier turns into a summary and writes the original messages to a file on disk under an identifier; query_memory lets the agent ask a question against those stored raw messages later. Nothing is thrown away, so the compression is lossless in the sense that matters, and the agent, not a fixed threshold, decides when to call it.

Production harnesses do something similar with more guardrails. Arize compared four open agent harnesses, Pi, OpenClaw, Claude Code and Letta, and found that all four hard-cap file reads, support offset and limit pagination, cap the size of tool results, isolate sub-agent sessions from the parent, and run LLM-powered compaction triggered by a token threshold. Arize reports, for example, that Claude Code rejects a file read over a 256KB byte cap before opening it and then counts the output against a 25,000-token budget, and that Letta keeps files in a vector store and shows the agent a truncated view, evicting the least recently used open file when too many are open.

Sub-agents are the cheapest context management available. In Pi, OpenClaw and Claude Code's default path, Arize found, a sub-agent starts without the parent's conversation history and gets the delegated task as its only message, so its window holds one job (Claude Code also has a newer fork path that copies the parent history into the child to share the prompt cache, and Letta does not fork at all). The hard part is the hand-back: what the worker returns, and what the orchestrator must keep about work still in flight so that a compaction cannot erase it, which we cover in async subagents and context.

For a cost comparison of summarising a long session against retrieving exact lines from it, see context compaction vs retrieval.

Agents can manage their own context, but mostly only when trained to

The CMU paper is the clearest evidence on who should decide, and it cuts both ways.

Equipping an agent with the two tools helps immediately. On BrowseComp-Plus, a Qwen3.5-9B agent scored 0.570 pass@1 as a plain ReAct agent, 0.608 and 0.614 with the threshold-based summarisers ReSum and ACON, and 0.635 with the ACM tools and no extra training. After the authors post-trained it on demonstrations of when to manage context and when not to, it reached 0.727, which the authors describe as a 27% relative gain on BrowseComp-Plus that comes close to open models 40 times its size (for reference, Qwen3.5-397B-A17B scored 0.653 and Gemini3-Flash 0.733 in the same table). On SWE-Bench Verified the same progression was 0.489, 0.508 and 0.530, and peak tokens per episode on BrowseComp-Plus fell from 68k with ReSum to 54k with the post-trained ACM agent. These are the authors' own results on 150 BrowseComp-Plus evaluation tasks, with DeepSearchQA used as an out-of-domain test, and they have not yet been replicated independently.

The other half of the finding matters more to anyone shipping an agent today: when GPT-5.5 was given the same tools, it made near-zero calls to either of them. A strong model that has not been trained to manage its context mostly will not, even when it has the means. The authors also note that simple tasks rarely need context management at all, because they finish before context pressure builds.

That is why production systems layer the decision. The harness enforces hard limits the model cannot forget (caps on reads and tool output, a compaction threshold), the model gets tools to compact and recall when it judges a turn is a good point to do so, and a system outside the run decides what is worth keeping once the run ends.

Unmanaged context grows cost quadratically and costs accuracy

Three pressures push context management out of prompt tuning and into the architecture.

Cost grows faster than the conversation. Cumulative input tokens under full-append grow quadratically with the number of turns, and bounded context grows linearly, which is where the roughly 6x and 13x figures above come from. Prompt caching lowers the price of the repeated prefix but does not change the shape of the curve; we work that through at current prices in how to reduce LLM token costs in long conversations.

A fuller window is a worse window. Anthropic describes an "attention budget" that models draw on as context grows and concludes that "context, therefore, must be treated as a finite resource with diminishing marginal returns." The CMU authors make the same point about agent traces in particular: long histories exceed an agent's effective capacity even on models with nominal windows of millions of tokens.

Naive compression can be worse than none. The ACE paper documents a case on the AppWorld benchmark where a context of 18,282 tokens scoring 66.7 was rewritten in one step into 122 tokens, and accuracy fell to 57.1, below the 63.7 the system scored with no adaptation at all. The summariser had no way to know what would be needed later. Bounding the budget is necessary, and how you bound it decides whether accuracy survives.

Across sessions and across agents: what outlives the run

Everything in the CMU framework lives for one episode; the offloaded messages sit in that task's workspace. Production agents serve the same person across weeks, and that is where the lifecycle half of agentic context management takes over: deciding which facts from this run become memory, scoping them to the right user and organisation, replacing them when they change, and putting only the relevant slice back into the next prompt.

What should persist is a narrow set. A decision the user made, a preference they stated and a correction they gave should outlive the session; tool output, intermediate reasoning and the raw transcript usually should not. Background agents make this sharper, because the sandbox is thrown away after each run and nothing persists unless the agent wrote it somewhere else, which we walk through in memory for background agents.

When several agents share context, the questions become governance questions. Atlan's guide to agent context management frames them as identity and entitlement checks that decide which context reaches an agent at runtime, revocation and expiry so that stale context stops shaping behaviour, and audit trails that record source IDs, policy decisions, timestamps and context versions. Our paper adds scope isolation as a first-class dimension: a read prefers the narrowest scope that applies, so one customer's data never leaks into another's session while shared organisational knowledge still reaches every user it should.

Eight production failures it prevents

Our paper maps each primitive to the failure its absence produces, and the list is a useful audit for any agent already in production:

  • Junk accumulation. Low-value and duplicate entries crowd out useful memory (architecting and ingesting).
  • Lost detail. Extraction keeps a vague paraphrase, so the specific fact can never be retrieved (ingesting).
  • Identity fragmentation. "Sarah", "Sarah Chen" and "SC" are stored as three people (ingesting).
  • Scope bleeding. One user's preferences surface in another user's session (scoping).
  • Cross-session amnesia. The user repeats themselves to every new session or sub-agent (scoping).
  • Retrieval on the critical path. Every turn stalls on a retrieval round trip (anticipating).
  • The accuracy cliff. Unvalidated compression removes what was needed later (compacting).
  • Quadratic cost growth. An unmanaged history makes cost rise with the square of length (compacting).

Context management is working when success rises and peak tokens fall

Measure the run as well as the answer. The CMU paper reports three numbers per agent that any team can reproduce on its own traces: task success (pass@1), the average peak token count per episode, and the number of tool calls, plus consistency across repeated trials. A context strategy that raises success while lowering peak tokens is working; one that lowers peak tokens and success together is the accuracy cliff arriving slowly.

For compaction specifically, check what survived. Our paper argues that compaction should be verifiable, which in practice means recording the facts a summary must preserve and testing that they are still answerable after it runs. For retrieval, ranking on what a memory changes in the next decision beats ranking on similarity once the budget is small, which we cover with a worked build in relevance is not usefulness. Across a conversation, track cumulative input tokens per conversation against turn count; a curve bending upward is full-append still happening somewhere.

Where to start, and when you do not need it

A single-turn application, or an agent whose tasks finish in a few steps, does not need agentic context management; the CMU authors observed the same thing for simple tasks. You need it once an agent runs long enough to hit its budget, serves the same person across sessions, or hands work between several agents.

A reasonable order for adding it, smallest change first:

  1. Instrument. Log tokens per call, peak tokens per run and cumulative tokens per conversation before changing anything.
  2. Cap what tools return. Every harness Arize studied caps file reads and tool results; it is the cheapest win available.
  3. Compact with a check. Summarise at a threshold, keep the raw messages somewhere retrievable, and verify the facts that must survive.
  4. Give the agent a recall tool. Let it query what was offloaded, as query_memory does, rather than trusting the summary alone.
  5. Isolate sub-agents. Send each worker its task, not the parent's transcript, and define what it hands back.
  6. Add a memory layer for what must outlive the run. Scope it per user and per organisation, record where each fact came from, and decide who may write and delete.

A folder of markdown files with injection rules, the MindStudio approach, is a sound way to manage instructions and reference knowledge that change slowly and are the same for every user. It is not a place to keep facts about individual people that get corrected, because files carry no scope, no provenance and no rule for what to do when two of them disagree.

Whether to build the lifecycle layer or source it comes down to how many of the five primitives your agents need and how many scopes they serve. One agent serving one user in one session needs a few of them and fits inside application code. Many agents serving many organisations, with isolation and an audit trail, need all five, and that is an infrastructure project which tends to grow quietly underneath the product.

Where Maximem Synap fits

Maximem Synap is the reference implementation described in our paper, and it maps onto the primitives directly. Custom Context Architecture generates a memory architecture for each agent from a description of what that agent does: what to extract, how aggressively, into which categories, how it is scoped and stored, and how it is retrieved and ranked. Agentic Compaction compresses conversations as they grow, and every pass returns a validation score and a preserved-facts count, so you know when the compression kept the signal. Anticipatory Retrieval works out what the agent is about to need and puts it in reach before it is asked for. Memory is isolated by default across your account, your tenant, the individual person and the conversation, and every memory carries provenance: where it came from, what it replaced and why it changed. The paper's own summary sets out the argument in full, and the Synap documentation covers installation.

Frequently asked questions

What is agentic context management in simple terms?

It is the practice of deciding, continuously while an AI agent works, what information it holds in its context window, when it gets it, how long it keeps it and what it costs, and then deciding what from that run is worth remembering for the next one.

Where does the term agentic context management come from?

Two arXiv papers published three days apart in July 2026 use it as their title: Maximem's lifecycle paper by Gaurav Dadhich on 23 July, and the CMU paper by Xiaochuan Li and co-authors on 26 July. MindStudio was using the phrase for a file-and-rules approach in June 2026.

Is agentic context management the same as context engineering?

No. Context engineering decides which tokens go into a call. Agentic context management covers who makes that decision as a long task unfolds, how the context is compacted and recalled, and what persists across sessions and scopes once the run ends.

Is agentic context management the same as Agentic Context Engineering (ACE)?

No. ACE evolves a reusable playbook of strategies across tasks through generation, reflection and curation. Agentic context management, in both July 2026 papers, manages the context inside a run and, in our framing, its lifecycle across sessions.

Can an LLM manage its own context?

It can when it has tools for it and has been trained to use them. In the CMU study a post-trained Qwen3.5-9B agent with compaction and recall tools went from 0.570 to 0.727 pass@1 on BrowseComp-Plus, while GPT-5.5 given the same tools made near-zero calls to them.

Does a bigger context window remove the need for context management?

No. A bigger window raises the ceiling, but cost under full-append still grows quadratically with conversation length, models still have a limited attention budget, and nothing in the window survives the end of the session.

From the team at Maximem

Stop rebuilding agent memory from scratch

Maximem Synap is the context management layer we built after hitting every problem in this post ourselves. Persistent recall across sessions, entity resolution and conscious forgetting, in Python, TypeScript and REST.

Looking for more to read? See our directory of the best engineering blogs to follow.