Memory
Bedrock agents have persistent memory that maintains context across runs. The memory system uses hierarchical summarization to keep long conversations within LLM token limits.How Memory Works
Messages are progressively summarized into higher-level buckets:- Raw Messages — summarized every 5 minutes into 5-Minute Summaries
- 5-Minute Summaries — rolled up every hour into Hourly Summaries
- Hourly Summaries — rolled up every day into Daily Summaries
- Daily Summaries — rolled up every week into Weekly Summaries
- Weekly Summaries — rolled up every month into Monthly Summaries
Memory Context Structure
When an agent runs, it receives memory as two parts:Historical Context (Cached)
Stable summaries from monthly → daily level. This content rarely changes and is cached by Claude for efficiency.Recent Context (Dynamic)
Recent activity from hourly → 5-minute summaries plus raw messages. This changes frequently. The prompt is structured in four sections, top to bottom:- System Prompt — cached
- Historical Context (monthly/weekly/daily summaries) — cached
- Recent Context (hourly/5-min summaries + raw messages) — not cached
- Current Time + Wakeup — not cached
Logging Messages
Log messages to agent memory:- Injecting external conversations (SMS, email) into memory
- Seeding agents with initial context
- Syncing state from external systems
Getting Memory Context
Retrieve the formatted memory context (what the agent sees):Getting Recent Messages
Retrieve raw recent messages (before summarization):Summarization Model
Memory summarization uses a separate, smaller model (default:claude-haiku-4-5) for efficiency. Configure per-agent:
Resetting Memory
Clear all memory for an agent:Memory and Tool Calls
When agents make tool calls, the calls and results are automatically logged to memory:Memory Timestamp Handling
Messages can include explicit timestamps:Prompt Caching Benefits
The hierarchical memory structure enables prompt caching with Claude:| Content Type | Cache Status | Why |
|---|---|---|
| Tool descriptions | Cached | Rarely changes |
| System prompt | Cached | Static |
| Historical memory | Cached | Changes slowly |
| Recent memory | Not cached | Changes every run |
Best Practices
Let It Summarize
Don’t manually manage memory - let the summarization system work.
Use Timestamps
Include accurate timestamps when logging external messages.
Reset Sparingly
Only reset memory when truly needed - context is valuable.
Check Context
Use memory-context endpoint to debug what agents see.