Skip to content
AI agents in production

How do AI agents manage memory and context?

A model only knows what is in its context window on each call, so an agent's memory has to be engineered. Short-term memory is the state of the current task, saved after each step so it can resume. For long tasks, agents compact old history into summaries, write structured notes outside the context and re-read them, or hand subtasks to sub-agents that return only a summary. Long-term memory is a store the agent retrieves from when relevant.

Published
22 October 2026
Sources checked
22 October 2026
From
Kramiva

01

Why context is the constraint

Anthropic describes context as a finite resource with diminishing returns: as the context window fills, a model's ability to recall information from it degrades, an effect it calls context rot. Giving an agent everything is therefore not the same as giving it what it needs.

02

Techniques

From Anthropic's “Effective context engineering for AI agents”, with framework support noted.

  • Compaction: summarise a long conversation and continue from the summary
  • Structured note-taking: the agent writes progress and decisions to a file or store and reads them back later
  • Sub-agents: a sub-agent explores with its own clean context and returns a condensed result
  • Persisted state: LangGraph saves a checkpoint per step, keyed by thread, so a conversation or task can resume
  • Retrieval: long-term facts live in a database or index and are fetched only when relevant

03

An illustrative example

A support assistant handling a long case keeps a short case file: the customer's issue, what has been tried, and what was promised. Each new step reads the case file instead of the entire history. Older messages are summarised into it, and the full transcript stays in storage for audit rather than in the model's context.

04

Trade-offs

Every summary loses detail, and a lost detail may be the one that mattered. Sub-agents keep contexts clean but, as Cognition argues, can lose the shared understanding that keeps work consistent. Stored memory raises data-protection questions: what is kept, for how long, and who can see it.

Where Kramiva fits

Kramiva's assistants answer from a client's own documents with source citations, so a retrieved fact can always be traced to where it came from.

Sources

  1. Effective context engineering for AI agents — Anthropic, 29 September 2025
  2. LangGraph persistence — LangChain
  3. Don't Build Multi-Agents — Cognition, 12 June 2025

Accessed 22 October 2026. Kramiva is not affiliated with these publishers.

Start

Tell us what you are building.

A short brief gets you a real reply from a founder within one business day — an honest read on fit, scope, and budget.