Skip to content

feat: Add SummarizingConversationManager#524

Draft
jsamuel1 wants to merge 1 commit intostrands-agents:mainfrom
jsamuel1:feat/summarizing-conversation-manager
Draft

feat: Add SummarizingConversationManager#524
jsamuel1 wants to merge 1 commit intostrands-agents:mainfrom
jsamuel1:feat/summarizing-conversation-manager

Conversation

@jsamuel1
Copy link
Contributor

Implements summarizing conversation manager that preserves context by summarizing older messages instead of simply trimming them.

Features

  • Configurable summary ratio (0.1-0.8, default 0.3)
  • Configurable recent message preservation (default 10)
  • Two summarization paths: direct model call or dedicated agent
  • Tool pair boundary detection to maintain conversation validity
  • Async hook integration with AfterModelCallEvent

Testing

  • 27 comprehensive unit tests covering all functionality
  • All 841 tests pass with no type errors
  • 94.28% statement coverage, 88.88% branch coverage

Closes #279

Implements summarizing conversation manager that preserves context by
summarizing older messages instead of simply trimming them.

Features:
- Configurable summary ratio (0.1-0.8, default 0.3)
- Configurable recent message preservation (default 10)
- Two summarization paths: direct model call or dedicated agent
- Tool pair boundary detection to maintain conversation validity
- Async hook integration with AfterModelCallEvent

Closes strands-agents#279
@github-actions github-actions bot added the strands-running <strands-managed> Whether or not an agent is currently running label Feb 13, 2026
private readonly _preserveRecentMessages: number
private readonly _summarizationAgent?: Agent
private readonly _summarizationSystemPrompt?: string
private _summaryMessage?: Message

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Unused private field

_summaryMessage is stored but never read or exposed. The Python SDK uses this field for session persistence via restore_from_session() and get_state() methods.

Suggestion: Either remove this field if session persistence isn't needed, or implement the session persistence methods to maintain API parity with the Python SDK.

*
* @throws ContextWindowOverflowError If no valid split point can be found.
*/
private adjustSplitPointForToolPairs(messages: Message[], splitPoint: number): number {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Duplicated logic with SlidingWindowConversationManager

This tool pair boundary detection logic is nearly identical to the logic in SlidingWindowConversationManager.reduceContext() (lines 131-159). Consider extracting this to a shared utility function in a common location (e.g., a utils.ts file in this directory).

Suggestion: Create a shared function like findValidSplitPoint(messages: Message[], initialSplitPoint: number): number that both conversation managers can use.

try {
summarizationAgent.messages.splice(0, summarizationAgent.messages.length, ...messages)
const result = await summarizationAgent.invoke('Please summarize this conversation.')
return new Message({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Summary message role may be confusing

The summary is returned as a user role message, which may be unexpected since it's system-generated content. Consider documenting this design decision or using a different approach.

The Python SDK does the same thing ({"role": "user"}), so this is consistent, but it might be worth adding a comment explaining why the summary is injected as a user message.

@@ -0,0 +1,198 @@
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Unrelated file included in PR

This LSP configuration file is unrelated to the SummarizingConversationManager feature and should be removed from this PR. It appears to be IDE-specific configuration that was accidentally committed.

@github-actions
Copy link

Assessment: Request Changes

This PR introduces a well-implemented SummarizingConversationManager that closely follows the Python SDK design. The core functionality is solid with good test coverage.

Review Categories
  • Unrelated Files: .kiro/settings/lsp.json should be removed from this PR
  • Code Duplication: Tool pair boundary detection logic should be extracted to a shared utility with SlidingWindowConversationManager
  • API Completeness: Consider adding session persistence methods (getState/restoreFromSession) for Python SDK parity
  • API Review: This introduces a new public abstraction customers will frequently use - consider adding needs-api-review label per API Bar Raising guidelines

The implementation is well-structured and the tests are comprehensive. Good work aligning with the Python SDK design!

@github-actions github-actions bot removed the strands-running <strands-managed> Whether or not an agent is currently running label Feb 13, 2026
@guenhter
Copy link

@jsamuel1 Love to get this. Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Summarization Conversation Manager

2 participants