AWS AgentCore Memory Gets Nightly TTL, Decay Scoring, and LLM Consolidation
In this article
Production deployments of Amazon Bedrock AgentCore agents accumulate memory entries from every conversation they handle, and without active management that accumulation becomes a liability. AWS documented two concrete failure modes from observed customer deployments: a customer support agent that surfaced a billing dispute resolved four months earlier as though it were still open, and an IT agent that repeated deployment advice from a superseded runbook because no mechanism had cleared the outdated procedural entry. A September 4, 2026 AWS Machine Learning blog post from Akarsha Sehwag, Himanshu Sah, and Nicolò Cosimo Albanese responds to those failure modes with a deployable AWS CDK stack that enforces three complementary lifecycle policies via a nightly Step Functions workflow.
Memory Taxonomy and Retention Tiers
The framework establishes a three-type vocabulary that drives every downstream policy decision. Episodic memories — timestamped, session-bound conversation records stored in AgentCore's Summary and Episodic strategies — are the highest-volume and lowest-durability type, and the first candidates for expiration. Semantic memories are distilled, conversation-decoupled facts ("the user prefers us-east-1 for deployments") that are compact and durable, warranting longer retention and making them prime consolidation targets. Procedural memories encode learned tool-use workflows stored as reflections tied to episodic memory; they carry the longest retention window and the highest pruning bar.
The TTL defaults reflect these durability differences: summary memories expire after 30–60 days, semantic memories after 6–12 months, and procedural memories carry no recommended TTL ceiling. The single deployable memoryTtlDays parameter defaults to 90 days for episodic records and runs first in the nightly sequence — before scoring or consolidation — to avoid spending compute on records that are already compliance liabilities. AgentCore memory provides no built-in auto-delete TTL, so the pruner queries ListMemoryRecords using the system field x-amz-agentcore-memory-createdAt with a BEFORE filter to isolate records older than the cutoff, then deletes them.
Relevance Decay Scoring and Archetype Tuning
Surviving records are scored by a three-term weighted exponential formula combining creation recency, last-access recency, and access frequency. With default weights — W_RECENCY = 0.4, W_ACCESS = 0.35, W_FREQUENCY = 0.25 — and MAX_ACCESS_BASELINE = 50, the score falls in [0.0, 1.0] when weights sum to 1.0. The operator-facing control is pruneDays: the number of days after which an unaccessed memory's score drops below the relevance threshold, converted internally via decay_rate = -ln(threshold) / prune_days. With the defaults of pruneDays = 45 and threshold = 0.3, this yields decay_rate ≈ 0.02676.
Because AgentCore's MemoryRecordSummary does not expose a lastAccessedAt field, access data is sourced from AWS CloudTrail. The CDK stack configures a trail with advanced event selectors that capture GetMemoryRecord data events, and the Memory Scorer Lambda aggregates those logs over a 25-hour lookback window, merging results with a persistent access ledger in S3 to accumulate lifetime frequency signal. Recommended pruneDays values vary by agent archetype:
| Agent Type | pruneDays | Rationale |
|---|---|---|
| Real-time support bot | 7 | Tickets resolve in hours or days; old context is not needed |
| Sales / onboarding agent | 21 | Deals close in weeks; stale leads pollute context |
| General assistant | 45 | Balanced retention for mixed workloads |
| IT helpdesk / ops agent | 90 | Incident patterns repeat seasonally |
| Legal / compliance advisor | 180 | Precedents stay relevant for months |
LLM-Based Consolidation and Quality Regression Testing
Memories that score below the relevance threshold are batched — default batch size 10 — and submitted to the Memory Consolidator Lambda, which invokes Claude Sonnet 4.5 (anthropic.claude-sonnet-4-5-20250929-v1:0) via Amazon Bedrock to merge related entries into a single compact semantic record. The consolidation prompt instructs the model to output a JSON object with a summary, a confidence float between 0.0 and 1.0, and a key_facts list. The merged record is written back to AgentCore memory and the originals are deleted; if Bedrock fails, originals are retained unchanged and failed deletions are logged for manual review. The authors note that consolidation is lossy by design and recommend archiving originals to cold storage in high-stakes domains, and configuring Amazon Bedrock Guardrails with grounding checks as production requirements.
Regression testing follows a before-and-after pattern. Each test case specifies a question, expected response criteria, and a min_quality_score. AgentCore Evaluations — an LLM-as-judge subsystem — scores agent responses on a normalized 0.0–1.0 scale before and after the nightly workflow; a test case fails only when post_lifecycle_score falls below min_quality_score. The sample run in the source shows two test cases passing with baseline/post scores of 0.82/0.85 and 0.74/0.71 against minimums of 0.70 and 0.60 respectively — a methodology consistent with the principle that infrastructure governance, not better models, unlocks safe agent deployment.
Compliance Architecture and Cost Profile
GDPR right-to-be-forgotten is handled by a dedicated deletion Lambda that lists all memory records for a given user_id namespace, deletes them individually via DeleteMemoryRecord, and returns a structured response with deleted_count and any failed_memory_ids for partial-failure recovery. Every memory mutation — scoring, consolidation, pruning, GDPR deletion — emits structured JSON to CloudWatch Logs with action type, memory ID, and ISO 8601 timestamp. The CDK stack also provisions a MemoryLifecycleAuditTrail CloudTrail trail with file validation enabled, delivering an immutable audit record to S3.
All configurable parameters — memoryTtlDays, relevanceThreshold, consolidationBatchSize, pruneDays, the three scoring weights, and maxAccessBaseline — are injected at deploy time via CDK context flags, requiring no code changes for tuning. The primary cost driver is Bedrock consolidation invocations. For an agent with 1,000 memories where 20 percent score below threshold, expect roughly 20 Bedrock invocations per nightly run at approximately $0.01–$0.02. Scaling to 100,000 memories pushes potential monthly cost to $50–$100. The recommended mitigation is raising the relevance threshold to reduce consolidation volume before that scale is reached.
Teams building agentic-era systems that process high interaction volumes over weeks or months — customer support bots, sales advisors, IT helpdesk agents — now have a concrete architectural playbook: TTL expiration for hard compliance ceilings, decay scoring for intelligent prioritisation, LLM consolidation for knowledge preservation, and regression testing to verify that none of it degrades response quality. Memory management is no longer an afterthought; it is a first-class infrastructure concern with cost, quality, and legal dimensions that all require explicit policy.
Related Reading
AWS AgentCore Runtime Hosts MCP Servers for Amazon Quick Agents
AWS shows how to deploy MCP servers on AgentCore Runtime and wire them into Amazon Quick chat agents via AgentCore Gateway with dual OAuth 2.0 auth flows.
AWS Agent Registry Is Now Generally Available on Bedrock AgentCore
AWS Agent Registry hits GA, giving engineering teams a governed catalog for AI agents, tools, and skills with semantic search and EventBridge-wired approval workflows.
Bedrock AgentCore Queries Cross-Account Knowledge Bases via STS Role
AWS shows how AgentCore agents can call RetrieveAndGenerate across account boundaries using a narrowly scoped IAM role assumed via STS.