AWS Builder Center
Why RAG Is Not Enough: Building an Always-On Memory Agent on AWS

Why RAG Is Not Enough: Building an Always-On Memory Agent on AWS

Serverless capture, scheduled consolidation, and cited recall — built from Bedrock, Lambda, S3, EventBridge, and DynamoDB. No vector database required.

Cloud Architect
Most AI agents have amnesia: they process information when asked, then forget everything. This article rebuilds the “always-on memory agent” pattern on AWS — a lightweight background loop that continuously captures, consolidates, and connects information, so an agent wakes up smarter every thirty minutes.

The problem

The usual answers to agent memory each stop one step short. A vector database with retrieval is passive: content gets embedded once and waits to be found, but nothing ever processes it again. Conversation summaries lose detail over time and never cross-reference each other. Knowledge graphs cross-reference beautifully but are expensive to build and painful to keep current.
What is missing is the thing human brains do during sleep: replay recent experience, connect it to what is already known, and compress it into something reusable. That is an active, scheduled process — not a lookup.
Approach
What it does well
Where it falls short
Vector store + retrieval
Fast similarity lookup over large corpora
Passive — content is embedded once, never re-processed
Conversation summaries
Cheap, simple to implement
Detail decays; summaries never reference each other
Knowledge graphs
Rich, explicit relationships
Expensive to build and maintain by hand
Always-on memory loop
Actively links and compresses notes on a schedule
Needs a scheduled process and a durable store (this article)

The architecture on AWS

The original project runs as a single local Python process with Gemini and SQLite. The AWS translation splits the same three responsibilities across managed services, so nothing depends on a long-lived process: capture is event-driven, consolidation is scheduled, and recall is a stateless request.
Three zones, one loop: files and text enter on the left, the memory loop enriches in the middle, questions are answered on the right.


How it works

1 — Capture

Anything dropped into the S3 inbox bucket — text, images, audio, video, or PDFs — triggers an EventBridge notification within seconds. The IngestAgent Lambda passes the file to a multimodal Bedrock call and stores a structured note: a short summary, the entities involved, the topics touched, and an importance score. Plain text can also arrive directly through API Gateway, useful for piping in chat transcripts or webhooks.
# IngestAgent (Lambda) — turn any captured file into a structured note
import boto3, json

bedrock = boto3.client("bedrock-runtime")
table = boto3.resource("dynamodb").Table("agent-notes")

def handler(event, context):
text = read_from_s3(event) # or event["body"] for API calls
result = bedrock.converse(
modelId="amazon.nova-lite-v1:0",
messages=[{"role": "user", "content": [{"text":
f"Extract summary, entities, topics, importance (0-1) "
f"as JSON from: {text}"}]}],
)
note = json.loads(result["output"]["message"]["content"][0]["text"])
note["consolidated"] = False
table.put_item(Item=note)

2 — Consolidate

Every thirty minutes, EventBridge Scheduler wakes the ConsolidateAgent. It reads every note that has not yet been consolidated, asks Bedrock to find connections between them, and writes two things back to DynamoDB: explicit links between related notes, and cross-cutting insights that none of the individual notes contained. This is the step every passive retrieval system skips — and the reason answers improve over time even when nothing new is captured.
The consolidation cycle: fire on schedule, read what is new, connect it, write insight back.


3 — Recall

A question arrives through API Gateway as plain natural language. The QueryAgent reads the relevant notes and every consolidation insight, then synthesizes an answer that cites which notes it drew on. Because insights already exist in the store, the agent is not reasoning from scratch on every request — it is reading conclusions it prepared earlier.
$ curl "https://<api-id>.execute-api.eu-west-1.amazonaws.com/query?q=what+should+I+focus+on"

"Based on your notes, prioritize:
1. Ship the API by March 15 [note 2]
2. Agent reliability gaps pair with the
reconstructive memory approach [notes 1, 3]
3. The smart-inbox idea validates the
market need for persistent memory [note 4]"

The memory record

Everything the loop produces lives in one DynamoDB table. A note written by the IngestAgent looks like this:
{
"pk": "note#2026-07-17T09:14:02Z",
"summary": "62% of assistant usage is code-related; agents fastest-growing",
"entities": ["Anthropic", "Claude", "AI agents"],
"topics": ["AI", "code generation", "agents"],
"importance": 0.8,
"source": "s3://memory-inbox/report.pdf",
"consolidated": false,
"links": [], // filled in by the ConsolidateAgent
"kind": "note" // notes vs. insights share the table
}
A single-table design keeps the loop simple: notes and insights share the same store and differ only by the kind attribute, so the QueryAgent reads both in one pass. Two access patterns matter, and each gets one index:
Access pattern
Who needs it
How it is served
Everything not yet consolidated
ConsolidateAgent, every 30 min
Sparse GSI on the consolidated attribute — only pending notes appear in it
All notes and insights, newest first
QueryAgent, per question
Table scan bounded by time-ordered keys; fine at personal/team scale
Expire raw notes after N days
Cost hygiene
DynamoDB TTL on an expiry attribute — insights are kept, raw notes age out

Deploying the loop

The whole system is a few dozen lines of infrastructure-as-code. The only piece people rarely reach for is EventBridge Scheduler, which replaces the in-process timer from the original project — here is the CDK for the consolidation cadence:
# CDK (Python) — the 30-minute heartbeat that makes the memory 'always on'
from aws_cdk import aws_scheduler as scheduler

scheduler.CfnSchedule(self, "ConsolidationCadence",
schedule_expression="rate(30 minutes)",
flexible_time_window={"mode": "OFF"},
target={
"arn": consolidate_fn.function_arn,
"roleArn": scheduler_role.role_arn,
},
)
Because the loop is defined entirely in code, it moves through environments like any other artifact: the same template deploys a personal store in one account and a team store in another, and changing the cadence is a one-line pull request rather than a redeploy of anything stateful.

Build it, or use AgentCore Memory?

AWS now ships a managed memory service inside Bedrock AgentCore, and it is fair to ask why anyone would assemble this loop by hand. The honest answer is that they solve overlapping but different problems, and the deciding factor is usually how much you want to own the consolidation logic.
Consideration
Operational effort
Bedrock AgentCore Memory
Consolidation logic
Yours — any strategy a Bedrock call can express
Built-in strategies, tuned by AWS
Multimodal capture
Yes — anything a converse call accepts via S3 inbox
Text-centric conversation events
Storage ownership
Your DynamoDB table, your retention rules
Managed store inside AgentCore
Works outside agents
Yes — any app can query the table
Designed for AgentCore-hosted agents
Operational effort
Low, but yours (a few Lambdas)
None
A reasonable rule: if your agents already run on AgentCore and conversational recall is the goal, use the managed service. Reach for this loop when the memory must ingest arbitrary files, serve consumers that are not agents, or apply consolidation logic that is genuinely yours — a research digest, a compliance-aware summarizer, a memory that deliberately forgets.

Running it in production

Three operational details separate a demo from something that runs for months unattended. First, idempotency: S3 can deliver an event more than once, so the IngestAgent keys notes on content hash rather than timestamp — a duplicate delivery becomes a no-op instead of a duplicate memory. Second, observability: a single CloudWatch dashboard with three numbers tells the whole story — notes captured today, minutes since the last successful consolidation, and Bedrock spend month-to-date. An alarm on the second number is the one that matters, because a silently stopped consolidation loop looks exactly like a healthy system until answers start feeling stale. Third, deletion: because every note carries its source, honoring a data-removal request is a query plus a cascade — delete the notes from a source, then re-run consolidation so no insight still summarizes something that no longer exists

What this costs to run

Everything in the loop is pay-per-use. With a thirty-minute consolidation cadence that is 48 Lambda invocations a day for the scheduler path, a Bedrock call per captured file, and single-digit DynamoDB reads and writes per cycle. For a personal or team-sized memory store, the monthly bill is dominated by nothing at all — every component sits comfortably inside typical low-traffic serverless usage, and there is no idle infrastructure because nothing runs between events.

Closing thoughts

The interesting part of the original project is not the storage choice — it is the loop. Passive retrieval answers “what did I store,” while a scheduled consolidation pass answers “what does what I stored mean.” On AWS that loop needs no servers, no vector database, and no embeddings pipeline: an S3 bucket to catch information, three small Lambda functions to think about it, a scheduler to keep thinking on a cadence, and DynamoDB to remember the conclusions. The pattern fits anywhere an agent should know more tomorrow than it does today.
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