Class Session

java.lang.Object
org.springframework.ai.session.Session

public final class Session extends Object
One continuous conversation between a user and an agent: its identity, its expiry and its metadata. An immutable value; the events are stored separately in the SessionRepository and read through the SessionService.

A session has no owner field. Who it belongs to is an attribute of its metadata, under a well-known key such as SessionAttributes.PRINCIPAL_NAME, set by the application and looked up with SessionRepository.findByMetadata(java.lang.String, java.lang.String).

Since:
2.1.0
Author:
Christian Tzolov
  • Method Details

    • id

      public String id()
      The session's identifier.
    • createdAt

      public Instant createdAt()
      When the session was created.
    • expiresAt

      public @Nullable Instant expiresAt()
      When the session expires, or null for never. A session the service creates always has an expiry, the request's time to live or the service's default; a session built directly has none unless Session.Builder.expiresAt sets one.
    • metadata

      public Map<String,Object> metadata()
      The metadata: the owner and agent attributes (SessionAttributes), tags, and whatever the application adds.
    • builder

      public static Session.Builder builder()