LlmEventSummarizer

class LlmEventSummarizer(val model: Model, val promptTemplate: String = DEFAULT_PROMPT_TEMPLATE) : EventSummarizer

An LLM-based event summarizer for context compaction.

This class is responsible for summarizing a provided list of events into a single compacted event. It is designed to be used as part of a context-compaction process such as sliding-window or tail-retention compaction.

When summarizeEvents is called with a list of events, this class formats the events, generates a summary using the model, and returns a new Event containing the summary within a com.google.adk.kt.events.EventCompaction on its Event.actions.

Constructors

Link copied to clipboard
constructor(model: Model, promptTemplate: String = DEFAULT_PROMPT_TEMPLATE)
constructor(model: Model)

Creates a summarizer using the default prompt template. Java callers need this because promptTemplate's default is not visible to them and its value is private.

Properties

Link copied to clipboard

The LLM used for summarization.

Link copied to clipboard

An optional template string for the summarization prompt. If not provided, a default template will be used. The template must contain a "{conversation_history}" placeholder, which is replaced with the formatted event history.

Functions

Link copied to clipboard
open suspend override fun summarizeEvents(events: List<Event>): Event?

Compacts the given events into a single Event.