Skip to content

SlidingWindowConversationManager

Defined in: src/conversation-manager/sliding-window-conversation-manager.ts:43

Implements a sliding window strategy for managing conversation history.

This class handles the logic of maintaining a conversation window that preserves tool usage pairs and avoids invalid window states. When the message count exceeds the window size, it will either truncate large tool results or remove the oldest messages while ensuring tool use/result pairs remain valid.

As a HookProvider, it registers callbacks for:

  • AfterInvocationEvent: Applies sliding window management after each invocation
  • AfterModelCallEvent: Reduces context on overflow errors and requests retry
new SlidingWindowConversationManager(config?): SlidingWindowConversationManager;

Defined in: src/conversation-manager/sliding-window-conversation-manager.ts:52

Initialize the sliding window conversation manager.

ParameterTypeDescription
config?SlidingWindowConversationManagerConfigConfiguration options for the sliding window manager.

SlidingWindowConversationManager

registerCallbacks(registry): void;

Defined in: src/conversation-manager/sliding-window-conversation-manager.ts:66

Registers callbacks with the hook registry.

Registers:

  • AfterInvocationEvent callback to apply sliding window management
  • AfterModelCallEvent callback to handle context overflow and request retry
ParameterTypeDescription
registryHookRegistryThe hook registry to register callbacks with

void

HookProvider.registerCallbacks