Class SessionMemoryClient

Object
akka.javasdk.impl.agent.SessionMemoryClient
All Implemented Interfaces:
SessionMemory

@InternalApi public final class SessionMemoryClient extends Object implements SessionMemory
INTERNAL USE Not for user extension or instantiation
  • Constructor Details

    • SessionMemoryClient

      public SessionMemoryClient(ComponentClient componentClient, akka.runtime.sdk.spi.EventLogClient eventLogClient, akka.javasdk.impl.serialization.Serializer serializer, AgentRegistry agentRegistry, akka.stream.Materializer materializer, com.typesafe.config.Config memoryConfig)
    • SessionMemoryClient

      public SessionMemoryClient(ComponentClient componentClient, akka.runtime.sdk.spi.EventLogClient eventLogClient, akka.javasdk.impl.serialization.Serializer serializer, AgentRegistry agentRegistry, akka.stream.Materializer materializer, SessionMemoryClient.MemorySettings memorySettings)
  • Method Details

    • addInteraction

      public void addInteraction(String sessionId, SessionMessage.MultimodalUserMessage userMessage, List<SessionMessage> messages)
      Description copied from interface: SessionMemory
      Adds an interaction between a user and an AI model to the session history for the specified session, supporting multimodal content.

      This overload accepts a SessionMessage.MultimodalUserMessage which can contain multiple content types including text and images, enabling multimodal interactions.

      Specified by:
      addInteraction in interface SessionMemory
      Parameters:
      sessionId - The unique identifier for the contextual session
      userMessage - The user message containing multimodal content (text, images, etc.)
      messages - All other messages generated during this interaction, typically AiMessage but also Tool Call responses.
    • addInteraction

      public void addInteraction(String sessionId, SessionMessage.UserMessage userMessage, List<SessionMessage> messages)
      Description copied from interface: SessionMemory
      Adds an interaction to the session history for the specified session.

      When userMessage is non-null, the user message is persisted followed by the response messages. When userMessage is null, only the response messages are persisted (a partial interaction, such as tool call responses completing a previous AI message).

      Specified by:
      addInteraction in interface SessionMemory
      Parameters:
      sessionId - The unique identifier for the contextual session
      userMessage - The content of the user message, or null for partial interactions
      messages - All other messages generated during this interaction, typically AiMessage but also Tool Call responses.
    • getHistory

      public SessionHistory getHistory(String sessionId)
      Returns the session history for the model.

      Two sources are queried, with different trade-offs:

      1. SessionMemoryEntity.fetchHistory(akka.javasdk.agent.SessionMemoryEntity.GetHistoryCmd). Hits an entity that may live on a different node and returns the whole history in a single response, so the payload is bounded by the cross-node message-size limit. The entity caps the history at akka.javasdk.agent.memory.limited-window.max-size: when the cap is reached it drops the oldest messages and signals via a SessionHistoryResult.Truncated reply. Cheap when the history fits, but cannot deliver more than the cap allows.
      2. EventLogClient.currentEventsForEntity(EventLogClient.Query). The runtime reads the journal locally (same node) and streams the events back chunked, so it is not bound by the cross-node message-size limit and never has to hold the full history in memory at once. More expensive than a single entity read, so we only pay for it when needed.

      Strategy: ask the entity first; if it replies Truncated, switch to the chunked journal stream so the model never sees an incomplete context.

      Specified by:
      getHistory in interface SessionMemory
      Parameters:
      sessionId - The unique identifier for the contextual session
      Returns:
      The complete session history containing all messages