Managing Agent State and Memory
This lesson explains how agents keep state to continue a conversation, track progress through a task and remember users across sessions, which the exam guide asks you to implement.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish conversation, task and long-term state.
- Choose AWS options for agent state.
- Keep state in managed stores rather than agent compute.
Kinds of state
Conversation state is the message history of the current session. Task state records progress through multi-step work, such as which approvals have been obtained. Long-term memory keeps facts and preferences about a user across sessions, such as "prefers email contact". Because context windows are finite and tokens cost money, agents cannot simply keep everything in the prompt; they need storage, summarisation and retrieval of relevant memories.
Kinds of agent state
AWS options
Bedrock Agents manage session state for a sessionId, accept session attributes (persist for the session and are passed to action group Lambda functions) and prompt session attributes (for the current turn), and can enable memory that summarises sessions for later ones. AgentCore Memory stores short-term memory as events per actor and session, and extracts long-term memory with built-in strategies: semantic (facts), user preferences and session summaries, or custom strategies; agents retrieve relevant memories by semantic search. For custom frameworks, DynamoDB is a common store for checkpoints and task state, and Step Functions holds state for deterministic workflows.
The following diagram shows where a travel-booking agent stores each kind of state: conversation events, long-term preferences and booking progress.

Where state lives
Design guidance
Agent state should live in managed stores rather than in the agent's compute, so that sessions survive restarts and the agent can scale across many instances; the compute itself stays stateless. Memory is scoped by user, or actor, to prevent information from leaking between users.
Memory also needs governance: retention periods limit how long it is kept, sensitive data is not stored unless necessary, and stored memory is encrypted. Long conversation histories are summarised rather than replayed in full, which keeps prompts short and costs down. The following table summarises the options.
| Need | Option |
|---|---|
| Pass context to tools within a session | Bedrock Agents session attributes |
| Remember users across sessions | AgentCore Memory long-term strategies or Bedrock Agents memory |
| Short-term conversation history | AgentCore Memory events |
| Checkpoint a custom agent's task progress | DynamoDB |
| Fixed multi-step process with waits | Step Functions |
A travel agent that remembers
A travel assistant built with Strands Agents on AgentCore Runtime should remember that a user prefers aisle seats and vegetarian meals, and resume a booking if the user returns hours later.
- Write each conversation turn as an AgentCore Memory event with the user as actor and the trip as session.
- Enable the user-preference strategy, which extracts "aisle seat" and "vegetarian" as long-term memories.
- Store booking progress (flight held, payment pending) in DynamoDB keyed by trip ID.
- On return, the agent retrieves preferences and booking state before responding.
Keeping state outside the runtime means a new session, even on different compute, continues where the user left off.
How is context passed to a Bedrock Agents Lambda action group?
Show answer
With session attributes.
Exam Tips
Remember for the exam
- Remember facts and preferences across sessions: AgentCore Memory long-term strategies.
- Pass context to Lambda action groups: session attributes.
- Checkpoint custom agent progress: DynamoDB.
- Keep compute stateless and state in managed stores.
- Scope memory per user and set retention.