Class ModelTextPart

All Implemented Interfaces:
PropertyChangeSource, ThoughtSignature, Rebindable
Direct Known Subclasses:
HostedCodeExecutionCallPart, HostedCodeExecutionResultPart, WebSearchCallPart

public class ModelTextPart extends TextPart implements ThoughtSignature
A specialized TextPart for content generated by an AI model.

Beyond standard text, this implementation is capable of encapsulating the model's internal 'Thinking Process'. It manages the visibility of these thoughts in the UI layer and maintains its own max-depth policy to optimize context window usage.

Author:
anahata
  • Field Details

    • thoughtSignature

      private byte[] thoughtSignature
      The signature byte array of the thought process, used for verification.
    • thought

      private boolean thought
      Indicates if this part represents internal model reasoning (thoughts).
  • Constructor Details

    • ModelTextPart

      public ModelTextPart(AbstractModelMessage message, String text, byte[] thoughtSignature, boolean thought)
      Constructs a new ModelTextPart.
      Parameters:
      message - The model message this part belongs to. Must be a AbstractModelMessage.
      text - The text content.
      thoughtSignature - The signature of the thought process as a byte array.
      thought - Whether this part represents a thought process.
  • Method Details

    • isThought

      public boolean isThought()
      Indicates if this text part represents a model thought process. For a generic TextPart, this is always false.

      Indicates whether this part contains internal model reasoning (thoughts) rather than direct conversational output.

      Overrides:
      isThought in class TextPart
      Returns:
      always false
    • getDefaultMaxDepth

      protected int getDefaultMaxDepth()
      Template method hook for subclasses to provide their specific default max depth policy. This is the fallback value used when no explicit maxDepth is set on the instance. Returns the default maximum depth to keep a text part in context, as defined in the agi configuration. Returns the default maximum depth for thoughts if this is a thought part, otherwise falls back to the standard text part depth.
      Overrides:
      getDefaultMaxDepth in class TextPart
      Returns:
      The default maximum depth for this part type.