HistoryCompressionStrategy

Represents an abstract strategy for compressing the history of messages in a AIAgentLLMWriteSession. Different implementations define specific approaches to reducing the context size while maintaining key information.

Example implementations:

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
data class Chunked(val chunkSize: Int) : HistoryCompressionStrategy

A concrete implementation of the HistoryCompressionStrategy that splits the session's prompt into chunks of a predefined size and generates summaries (TL;DR) for each chunk.

Link copied to clipboard

A strategy for compressing history by retaining only the last n messages in a session.

Link copied to clipboard

WholeHistory is a concrete implementation of the HistoryCompressionStrategy that encapsulates the logic for compressing entire conversation history into a succinct summary (TL;DR) and composing necessary messages to create a streamlined prompt suitable for language model interactions.

Functions

Link copied to clipboard
abstract suspend fun compress(llmSession: AIAgentLLMWriteSession, preserveMemory: Boolean, memoryMessages: List<Message>)

Compresses a given collection of memory messages using a specified strategy.