Class RagMessage

All Implemented Interfaces:
PropertyChangeSource, Rebindable

public class RagMessage extends UserMessage
A specialized UserMessage that represents just-in-time, ephemeral context provided by the environment (Retrieval-Augmented Generation).

This message and its parts are not part of the persistent conversation history and are exempt from all pruning logic.

Author:
Anahata
  • Constructor Details

    • RagMessage

      public RagMessage(Agi agi)
      Constructs a new RagMessage.
      Parameters:
      agi - The parent agi session.
  • Method Details

    • isEffectivelyPruned

      public boolean isEffectivelyPruned()
      Overrides the default pruning logic to declare that this message is ephemeral and should never be pruned. This is the key to preventing the pruning system from trying to access the (null) Agi context of this non-history message.
      Overrides:
      isEffectivelyPruned in class AbstractMessage
      Returns:
      Always false.
    • getParts

      public List<AbstractPart> getParts(boolean includePruned)
      Overrides the default part filtering logic. Since a RagMessage is always ephemeral and relevant for the current turn, it always returns all of its parts, regardless of the pruning flag.
      Overrides:
      getParts in class AbstractMessage
      Parameters:
      includePruned - This parameter is ignored.
      Returns:
      A new list containing all parts of this message.
    • getFrom

      public String getFrom()
      Gets the identity of the sender of this message. For user messages, this is typically the user's name. For model messages, it's the model ID. For tool messages, it's the identity of the execution context.

      Returns the user's identity formatted as 'username@device'.

      Overrides:
      getFrom in class UserMessage
      Returns:
      The sender's identity.
    • shouldCreateMetadata

      public boolean shouldCreateMetadata()
      Hook for subclasses to declare if they should generate in-band metadata headers.
      Overrides:
      shouldCreateMetadata in class AbstractMessage
      Returns:
      true if metadata headers should be generated.