Record Class TieredContextLoader.LoadedContext

java.lang.Object
java.lang.Record
com.tnsai.memory.strategy.TieredContextLoader.LoadedContext
Record Components:
recentMessages - messages from Tier 1 (verbatim recent turns)
summary - summary of older messages from Tier 2, null if no older messages
relevantMessages - messages from Tier 3 (semantic search results)
estimatedTokens - estimated total tokens across all tiers
Enclosing class:
TieredContextLoader

public static record TieredContextLoader.LoadedContext(List<Map<String,Object>> recentMessages, String summary, List<Map<String,Object>> relevantMessages, int estimatedTokens) extends Record
Result of tiered context loading.
  • Constructor Details

    • LoadedContext

      public LoadedContext(List<Map<String,Object>> recentMessages, String summary, List<Map<String,Object>> relevantMessages, int estimatedTokens)
      Creates an instance of a LoadedContext record class.
      Parameters:
      recentMessages - the value for the recentMessages record component
      summary - the value for the summary record component
      relevantMessages - the value for the relevantMessages record component
      estimatedTokens - the value for the estimatedTokens record component
  • Method Details

    • toMessageList

      public List<Map<String,Object>> toMessageList()
      Combines all tiers into a single ordered message list.

      Order: [summary system message] + [relevant search results] + [recent messages]

      This ordering ensures:

      • Summary provides high-level context at the start
      • Relevant past messages add specific detail
      • Recent messages are closest to the end (most visible to LLM)
      Returns:
      combined message list ready for LLM context
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • recentMessages

      public List<Map<String,Object>> recentMessages()
      Returns the value of the recentMessages record component.
      Returns:
      the value of the recentMessages record component
    • summary

      public String summary()
      Returns the value of the summary record component.
      Returns:
      the value of the summary record component
    • relevantMessages

      public List<Map<String,Object>> relevantMessages()
      Returns the value of the relevantMessages record component.
      Returns:
      the value of the relevantMessages record component
    • estimatedTokens

      public int estimatedTokens()
      Returns the value of the estimatedTokens record component.
      Returns:
      the value of the estimatedTokens record component