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.

Registers hooks for:

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

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

Initialize the sliding window conversation manager.

ParameterTypeDescription
config?SlidingWindowConversationManagerConfigConfiguration options for the sliding window manager.

SlidingWindowConversationManager

ConversationManager.constructor

readonly name: "strands:sliding-window-conversation-manager" = 'strands:sliding-window-conversation-manager';

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

Unique identifier for this conversation manager.

ConversationManager.name

initAgent(agent): void;

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

Initialize the plugin by registering hooks with the agent.

Registers:

  • AfterInvocationEvent callback to apply sliding window management
  • AfterModelCallEvent callback to handle context overflow and request retry (via super)
ParameterTypeDescription
agentLocalAgentThe agent to register hooks with

void

ConversationManager.initAgent


reduce(options): boolean;

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

Reduce the conversation history in response to a context overflow.

Attempts to truncate large tool results first before falling back to message trimming.

ParameterTypeDescription
optionsConversationManagerReduceOptionsThe reduction options

boolean

true if the history was reduced, false otherwise

ConversationManager.reduce