SlidingWindowTransformer

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

maxMessages

Maximum number of messages to retain

preserveSystemMessages

When true, preserves all SystemMessages regardless of position

Constructors

Link copied to clipboard
constructor(maxMessages: Int, preserveSystemMessages: Boolean = true)

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.