Package akka.javasdk.impl.agent
Class SessionMemoryClient
Object
akka.javasdk.impl.agent.SessionMemoryClient
- All Implemented Interfaces:
SessionMemory
INTERNAL USE Not for user extension or instantiation
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSessionMemoryClient(ComponentClient componentClient, akka.runtime.sdk.spi.EventLogClient eventLogClient, akka.javasdk.impl.serialization.Serializer serializer, AgentRegistry agentRegistry, akka.stream.Materializer materializer, SessionMemoryClient.MemorySettings memorySettings) 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) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInteraction(String sessionId, SessionMessage.MultimodalUserMessage userMessage, List<SessionMessage> messages) Adds an interaction between a user and an AI model to the session history for the specified session, supporting multimodal content.voidaddInteraction(String sessionId, SessionMessage.UserMessage userMessage, List<SessionMessage> messages) Adds an interaction to the session history for the specified session.getHistory(String sessionId) Returns the session history for the model.
-
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:SessionMemoryAdds 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.MultimodalUserMessagewhich can contain multiple content types including text and images, enabling multimodal interactions.- Specified by:
addInteractionin interfaceSessionMemory- Parameters:
sessionId- The unique identifier for the contextual sessionuserMessage- 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:SessionMemoryAdds an interaction to the session history for the specified session.When
userMessageis non-null, the user message is persisted followed by the response messages. WhenuserMessageis null, only the response messages are persisted (a partial interaction, such as tool call responses completing a previous AI message).- Specified by:
addInteractionin interfaceSessionMemory- Parameters:
sessionId- The unique identifier for the contextual sessionuserMessage- The content of the user message, or null for partial interactionsmessages- All other messages generated during this interaction, typically AiMessage but also Tool Call responses.
-
getHistory
Returns the session history for the model.Two sources are queried, with different trade-offs:
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 atakka.javasdk.agent.memory.limited-window.max-size: when the cap is reached it drops the oldest messages and signals via aSessionHistoryResult.Truncatedreply. Cheap when the history fits, but cannot deliver more than the cap allows.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:
getHistoryin interfaceSessionMemory- Parameters:
sessionId- The unique identifier for the contextual session- Returns:
- The complete session history containing all messages
-