AWS Builder Center
# Your Agent Remembers. Can You Trust It?
### Memory and context engineering for AI agents on AWS

# Your Agent Remembers. Can You Trust It? ### Memory and context engineering for AI agents on AWS

Your agent forgets too much, then remembers too much and the bill climbs. A practical guide to memory and context engineering on AWS: short-term vs long-term memory, what to keep, a memory budget, and the four failure modes that break continuity.

Senior Manager - Industrial AI - Accenture Solutions Pvt Ltd
You proved it works (Part 5) and you tuned the bill (Part 6). Then a user who spoke to your agent last Tuesday comes back, and the agent greets them like a stranger. It re-asks three things it was already told. The session that should have taken two turns takes nine.
So you fix it. You start feeding the whole history back into every prompt. Now the agent remembers everything, including a preference the user changed a month ago, a cancelled order it still treats as active, and a stray instruction from an unrelated conversation. The bill you carefully controlled in Part 6 quietly doubles again, because every turn now drags a growing transcript through the model.
That is the memory problem in one paragraph. Forget too much and the agent is useless. Remember too much and it is expensive, slow, and occasionally wrong in ways that are hard to trace. Getting this right is not a storage question. It is an engineering discipline, and on AWS it has a fairly clean shape.

Two kinds of memory, and they are not the same job

It helps to stop saying "memory" as if it were one thing. Agentic systems need two very different capabilities, and Amazon Bedrock AgentCore Memory separates them for exactly this reason.
Short-term memory is the working context of a single session. It is the running record of what was said and done in this conversation, so the agent stays coherent across turns and can recover if the process restarts mid session. In AgentCore Memory you write these as raw events against a session identifier and an actor identifier, and you read them back when you need the thread of the current interaction. Think of it as the agent's short-term recall for the task in front of it.
Long-term memory is what survives after the session ends. You almost never want to keep the raw transcript forever. What you want are the durable insights: a summary of what happened, the stable facts the user gave you, and their preferences. AgentCore Memory generates this asynchronously in the background. It reads the raw events and, using a memory strategy, extracts and consolidates the parts worth keeping, then stores them so a future session can retrieve them by relevance.
The distinction matters because the two have different lifespans, different costs, and different failure modes. Treating a transcript as if it were knowledge is how agents end up both forgetful and expensive at the same time.

What to keep, and what to throw away

The instinct to keep everything is the enemy. Long-term memory earns its value by being selective. AgentCore Memory gives you three built-in strategy types that map neatly onto what a production agent actually needs to remember:
  • Summarisation. Compress a long session into the few sentences a future session would need. The Tuesday conversation becomes "user was setting up billing alerts, completed two, blocked on IAM permissions" rather than forty turns of back and forth.
  • Semantic memory. The stable facts and knowledge worth carrying forward. Names, identifiers, configurations, decisions.
  • User preferences. The soft signals that personalise behaviour. Preferred format, tone, defaults, the shoe brand they mentioned once and expect you to remember.
You can run these as built-in strategies that AgentCore manages for you, or as custom strategies where you supply your own prompt and model to tune extraction for your domain. That second option is the difference between generic recall and memory that understands your business.
The mental model to hold: short-term memory is the raw material, long-term memory is the refined product, and the refining step is where you decide what your agent is allowed to carry into the future.

The bit everyone skips: memory is a cost lever

This is where Part 6 comes back to bite or reward you. Memory is not free, and it is not cheap by accident. There are two meters running.
The first is your token bill. Every fact you inject into a prompt is tokens, on every turn, forever. An agent that pastes its entire history into each request is not "remembering," it is setting fire to your context window. The four hundred tokens of transcript you carry needlessly are paid again and again, per turn, per user, at scale. Selective retrieval is not a nicety. It is the single biggest control you have over context cost.
The second is the memory service itself. Short-term events are billed per raw event you create, which keeps in-session context predictable. Long-term memory is billed on the records processed and stored each month plus the retrieval calls you make. The design lesson falls straight out of the pricing: write events deliberately, extract insights rather than hoarding raw data, and retrieve what is relevant rather than everything you have. You also choose how long raw events are retained, up to a year, which lets you keep short-term data only as long as it is useful and let the long-term layer hold the parts that matter.
Memory done well makes the agent both smarter and cheaper. Memory done lazily makes it dumber and more expensive at once. That is a rare kind of trade where the right engineering choice wins on both axes.

The four failure modes that quietly break continuity

Every article in this series has its four. Here are memory's.
1. Context bloat. The agent dumps the full history into every prompt "just in case." Latency creeps up, the bill climbs, and buried in a wall of context the model starts missing the one line that mattered. The fix is retrieval, not accumulation: pull the few relevant memories for this turn, not the archive.
2. Stale memory. The agent remembers a fact that is no longer true and acts on it with total confidence. The cancelled order, the old address, the preference the user reversed. Long-term memory without a notion of freshness or supersession is a confident liar. Extraction has to update and consolidate, not just append.
3. Cross-actor and cross-session leakage. One user's memory surfaces in another user's conversation, or a fact from an unrelated session bleeds into the current one. This is the failure mode that turns into an incident report. AgentCore Memory isolates by actor and by session precisely so this cannot happen by accident, but only if you set the actor and session identifiers correctly and namespace your long-term strategies. Get the identifiers wrong and you have built a privacy bug that looks like a feature.
4. Silent forgetting. Raw events expire on the retention window you set, and if you never configured a long-term strategy, nothing was extracted before they went. The agent looks fine in testing, where sessions are fresh, and quietly loses its memory in production a few days later. Forgetting should be a decision you made, never a default you did not notice.

Put a memory hygiene gate in CI

In Part 5 we gated correctness with a regression suite. In Part 6 we gated spend with a cost check. Memory deserves the same treatment, because every one of the failure modes above passes a casual demo and fails a real user three days later.
A memory hygiene gate is worth wiring into CI:
  • Recall test. Seed a fact in session one, start a fresh session as the same actor, and assert the agent recalls it. This catches silent forgetting before your users do.
  • Forgetting test. Update a fact, then assert the agent uses the new value and not the old one. This catches stale memory.
  • Isolation test. Write memory as actor A, query as actor B, and assert nothing leaks. This catches the incident before it ships.
  • Context budget assertion. Cap the tokens injected per turn and fail the build if a change blows past it. This keeps context bloat from silently re-inflating the bill you fixed last month.
None of these are exotic. They are four small tests that turn memory from a thing you hope works into a thing you can prove works.

The AWS shape of it

Wiring this together stays refreshingly boring, which is the point.
  • Amazon Bedrock provides the model that does the reasoning and, if you use custom strategies, the extraction.
  • AgentCore Memory provides both layers as a managed service: short-term events keyed by session and actor, and long-term records produced asynchronously by your chosen strategies, organised by namespace so retrieval stays scoped and relevant.
  • Strands Agents wires the loop: capture the turn as an event, retrieve the relevant memories before the next model call, and keep the agent's working context lean.
One honest caveat: AgentCore is in preview and the surface can change, so pin what you depend on and read the release notes before you lean on a specific behaviour in production.

The through line

The series has been building one argument. An agent that works (Part 5) and that you can afford (Part 6) still is not a product until it can hold a thread across time without lying, leaking, or bloating. Memory is what turns a clever demo into something a user trusts on Tuesday because it remembered Monday.
Remember on purpose. Forget on purpose. Retrieve what matters, prove it in CI, and let the managed layer carry the plumbing.


Stack: Amazon Bedrock · AgentCore · Strands Agents
 #agents   #agentic-ai   #memory   #amazon-bedrock-agentcore   #context-engineering 
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article