ChatMemoryPreProcessor
An interface for pre-processing messages before they are stored or loaded in the chat memory.
Preprocessors are applied in order when messages are loaded from or stored to the history provider. They allow transforming the message list at each stage, enabling use cases such as sliding window truncation, message filtering, summarization, etc.
Note that the order of preprocessors matters. For example:
// Keeps at most 10 messages, then filters short ones from those 10
windowSize(10)
filterMessages { it.content.length <= 100 }
// Filters short messages first, then keeps the last 10 of those
filterMessages { it.content.length <= 100 }
windowSize(10)Content copied to clipboard