Sliding Window Transformer
class SlidingWindowTransformer(maxMessages: Int, preserveSystemMessages: Boolean = true) : ToolLoopTransformer
Transformer that maintains a sliding window of messages to manage context size.
Applies windowing in both transformBeforeLlmCall and transformAfterIteration to ensure bounded memory and context window usage.
Parameters
max Messages
Maximum number of messages to retain
preserve System Messages
When true, preserves all SystemMessages regardless of position
Functions
Link copied to clipboard
Transform history after iteration completes. Return modified list.
Link copied to clipboard
Transform LLM response before adding to history. Return modified message.
Link copied to clipboard
Transform tool result before adding to history. Return modified string.
Link copied to clipboard
Transform history before sending to LLM. Return modified list.