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)
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SlidingWindowConversationManager(config?): SlidingWindowConversationManager;Defined in: src/conversation-manager/sliding-window-conversation-manager.ts:57
Initialize the sliding window conversation manager.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
config? | SlidingWindowConversationManagerConfig | Configuration options for the sliding window manager. |
Returns
Section titled “Returns”SlidingWindowConversationManager
Overrides
Section titled “Overrides”ConversationManager.constructor
Properties
Section titled “Properties”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.
Overrides
Section titled “Overrides”Methods
Section titled “Methods”initAgent()
Section titled “initAgent()”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)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
agent | LocalAgent | The agent to register hooks with |
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”reduce()
Section titled “reduce()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | ConversationManagerReduceOptions | The reduction options |
Returns
Section titled “Returns”boolean
true if the history was reduced, false otherwise