Class TailRetentionEventCompactor

java.lang.Object
com.google.adk.summarizer.TailRetentionEventCompactor
All Implemented Interfaces:
EventCompactor

public final class TailRetentionEventCompactor extends Object implements EventCompactor
This class performs event compaction by retaining the tail of the event stream.
  • Keeps the retentionSize most recent events raw.
  • Compacts all events that never compacted and older than the retained tail, including the most recent compaction event, into a new summary event.
  • Triggers compaction only if the prompt token count exceeds the tokenThreshold.
  • The new summary event is generated by the BaseEventSummarizer.
  • Appends this new summary event to the end of the event stream.

This compactor produces a rolling summary. Each new compaction event includes the content of the previous compaction event (if any) along with new events, effectively superseding all prior compactions.

  • Constructor Details

    • TailRetentionEventCompactor

      public TailRetentionEventCompactor(BaseEventSummarizer summarizer, int retentionSize, int tokenThreshold)
  • Method Details

    • compact

      public io.reactivex.rxjava3.core.Completable compact(Session session, BaseSessionService sessionService)
      Description copied from interface: EventCompactor
      Compacts events in the given session. If there is compaction happened, the new compaction event will be appended to the given BaseSessionService.
      Specified by:
      compact in interface EventCompactor
      Parameters:
      session - the session containing the events to be compacted.
      sessionService - the session service for appending the new compaction event.
      Returns:
      the Event containing the events summary.