Class SessionMemoryEntity


@Component(id="akka-session-memory", name="Agent Session Memory", description="Stores the recent conversation history for each agent session, including user, AI, and tool messages.\nUse this component to view or inspect the memory that the agents uses for context during interactions.\n") @EnableReplicationFilter public final class SessionMemoryEntity extends EventSourcedEntity<SessionMemoryEntity.State,SessionMemoryEntity.Event>
Built-in Event Sourced Entity that provides persistent session memory for agent interactions with the AI model.

SessionMemoryEntity maintains a limited history of contextual messages in FIFO (First In, First Out) style, automatically managing memory size to prevent unbounded growth. It serves as the default implementation of session memory for agents.

Automatic Registration: This entity is automatically registered by the Akka runtime when Agent components are detected. Each session is identified by the entity id, which corresponds to the agent's session id.

Memory Management:

  • Configurable maximum memory size via akka.javasdk.agent.memory.limited-window.max-size
  • Automatic removal of oldest messages when size limit is exceeded
  • Orphan message cleanup (removes AI/tool messages when their triggering user message is removed)

Direct Access: You can interact directly with session memory using ComponentClient.

Event Subscription: You can subscribe to session memory events using a Consumer to monitor session activity, implement custom analytics, or trigger compaction when memory usage exceeds thresholds.

The session memory has the multi-region replication filter enabled to only include the local region when using `request-region` primary selection. When accessed from another region the filter will be expanded to include the other region too.