Skip to content

SummarizingConversationManager

Defined in: src/conversation-manager/summarizing-conversation-manager.ts:95

Implements a summarization strategy for managing conversation history.

When a ContextWindowOverflowError occurs, this manager summarizes the oldest messages using a model call and replaces them with a single summary message, preserving context that would otherwise be lost.

new SummarizingConversationManager(config?): SummarizingConversationManager;

Defined in: src/conversation-manager/summarizing-conversation-manager.ts:103

ParameterType
config?SummarizingConversationManagerConfig

SummarizingConversationManager

ConversationManager.constructor

protected readonly _compressionThreshold: number;

Defined in: src/conversation-manager/conversation-manager.ts:116

ConversationManager._compressionThreshold


readonly name: "strands:summarizing-conversation-manager" = 'strands:summarizing-conversation-manager';

Defined in: src/conversation-manager/summarizing-conversation-manager.ts:96

A stable string identifier for this conversation manager.

ConversationManager.name

initAgent(agent): void;

Defined in: src/conversation-manager/conversation-manager.ts:170

Initialize the conversation manager with the agent instance.

Registers two hooks:

  1. AfterModelCallEvent: Overflow recovery — when a ContextWindowOverflowError occurs, calls ConversationManager.reduce with error set and retries if reduction succeeded.
  2. BeforeModelCallEvent: Proactive compression — when projected input tokens exceed the configured compression threshold, calls ConversationManager.reduce without error. The hook is always registered but only acts when proactive compression is enabled.

Subclasses that override initAgent MUST call super.initAgent(agent) to preserve overflow recovery and proactive compression behavior.

ParameterTypeDescription
agentLocalAgentThe agent to register hooks with

void

ConversationManager.initAgent


reduce(options): Promise<boolean>;

Defined in: src/conversation-manager/summarizing-conversation-manager.ts:124

Reduce the conversation history by summarizing older messages.

When error is set (reactive overflow recovery), summarization failure is rethrown with the original error as cause — the agent loop must not proceed with an overflow.

When error is undefined (proactive compression), summarization failure is logged and returns false — the model call proceeds regardless.

ParameterTypeDescription
optionsConversationManagerReduceOptionsThe reduction options

Promise<boolean>

true if the history was reduced, false otherwise

ConversationManager.reduce