Persist memory and filesystem
The harness persists state at two layers: conversation state in AgentCore Memory, and file state on the agent’s filesystem.
Memory. Attach an AgentCore Memory instance to the harness and every invocation saves the conversation automatically, scoped by session ID (and additionally by actor ID, if provided). On subsequent invocations with the same session ID, the agent’s history is loaded from Memory before it reasons, so it remembers what happened in previous turns, even after the underlying microVM session has expired. You do not need to pass previous messages yourself; just send the new message.
-
Short-term memory captures raw events (messages, tool calls) within a session.
-
Long-term memory extracts durable knowledge via configurable strategies (semantic, summarization, user preference, episodic, or custom) and makes them retrievable via semantic search in later sessions.
-
Actor ID - identifies the entity interacting with the agent (a user, another agent, or a system). Memory events are scoped by actorId + sessionId, so each actor has isolated memory. Long-term retrieval uses actorId as a template variable in namespace paths (e.g. /summary/{actorId}/{sessionId}/), mapping to the configured memory strategies.
Filesystem. If enabled, each session runs in a Firecracker microVM with a working filesystem. Files written during a session persist through the session’s lifetime. For state that needs to outlast a single session, mount S3-backed storage through AgentCore Runtime persistent filesystems.
Add memory
Example
The actorId determines whose memory is loaded. Long-term memory strategies (semantic, summarization, etc.) use the actorId to scope extracted knowledge - each actor gets their own isolated memory namespace. For more details on configuring long-term memory, see configuring long-term memory strategies.
Filesystem
Mount S3-backed persistent storage that survives session termination. Files written to the mount path persist across session restarts when using the same runtimeSessionId.
Example
Learn more: AgentCore Memory, create a memory store, long-term memory strategies, persistent filesystems on Runtime.
Related topics
-
Configure agents and models - configure models and system prompts
-
Environment and Skills - bring your own container with persistent storage mounts
-
Control cost with limits - execution limits