Class TailRetentionEventCompactor
java.lang.Object
com.google.adk.summarizer.TailRetentionEventCompactor
- All Implemented Interfaces:
EventCompactor
This class performs event compaction by retaining the tail of the event stream.
- Keeps the
retentionSizemost 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 Summary
ConstructorsConstructorDescriptionTailRetentionEventCompactor(BaseEventSummarizer summarizer, int retentionSize, int tokenThreshold) -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Completablecompact(Session session, BaseSessionService sessionService) Compacts events in the given session.
-
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:EventCompactorCompacts events in the given session. If there is compaction happened, the new compaction event will be appended to the givenBaseSessionService.- Specified by:
compactin interfaceEventCompactor- Parameters:
session- the session containing the events to be compacted.sessionService- the session service for appending the new compaction event.- Returns:
- the
Eventcontaining the events summary.
-