Skip to content

feat: Add SummarizingConversationManager#524

Open
jsamuel1 wants to merge 2 commits intostrands-agents:mainfrom
jsamuel1:feat/summarizing-conversation-manager
Open

feat: Add SummarizingConversationManager#524
jsamuel1 wants to merge 2 commits 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

@github-actions github-actions bot added the strands-running <strands-managed> Whether or not an agent is currently running label Feb 13, 2026
@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?

@jsamuel1
Copy link
Contributor Author

jsamuel1 commented Feb 28, 2026

@jsamuel1 Love to get this. Any update?

THanks for the prompt. I didn't see the comments above. Fixing now.

@jsamuel1
Copy link
Contributor Author

All automated review feedback has been addressed in the latest push:

  1. Unrelated file.kiro/settings/lsp.json removed, .kiro/ added to .gitignore
  2. Unused _summaryMessage field — Removed. Session persistence (getState/restoreFromSession) deferred to a follow-up issue covering all conversation managers.
  3. Code duplication — Extracted shared findValidSplitPoint() utility in src/conversation-manager/utils.ts, used by both SlidingWindowConversationManager and SummarizingConversationManager. Added unit tests.
  4. Summary role comment — Added explanatory comments for the user role design choice in both summary generation methods.

Re: API review label — happy to add needs-api-review if a maintainer thinks it's warranted.

@jsamuel1 jsamuel1 marked this pull request as ready for review March 1, 2026 00:29
@jsamuel1
Copy link
Contributor Author

jsamuel1 commented Mar 1, 2026

Re: session persistence — after merging upstream main, the new snapshot/session infrastructure (src/session/ + src/agent/snapshot.ts from #520 and #560) already handles this. takeSnapshot(agent) captures agent.messages which includes the post-summarization state, and loadSnapshot restores it. Since SummarizingConversationManager modifies agent.messages in-place, session persistence works out of the box without needing getState()/restoreFromSession() on the conversation manager itself.

@jsamuel1 jsamuel1 force-pushed the feat/summarizing-conversation-manager branch from efcac3d to a8495d9 Compare March 3, 2026 07:18
jsamuel1 added a commit to jsamuel1/sdk-typescript that referenced this pull request Mar 3, 2026
Combines the following feature branches:
- feat/summarizing-conversation-manager (PR strands-agents#524)
- feat/structured-output-integ-tests (PR strands-agents#588)
- feat/interrupt-system (PR strands-agents#586)
- feat/swarm-multi-agent (PR strands-agents#587)
- feat/graph-multi-agent (PR strands-agents#594)

All 1277 unit tests pass. No type errors.
@jsamuel1 jsamuel1 force-pushed the feat/summarizing-conversation-manager branch from 764e6cc to 4417301 Compare March 9, 2026 07:07
@jsamuel1 jsamuel1 force-pushed the feat/summarizing-conversation-manager branch from 4417301 to c09fa86 Compare March 9, 2026 20:53
@jsamuel1 jsamuel1 force-pushed the feat/summarizing-conversation-manager branch from c09fa86 to 7b5c8cb Compare March 18, 2026 23:25
Adds a conversation manager that uses the model to summarize older
messages when the context window fills up, preserving important
context while staying within token limits.

Includes reduceContext as a public method for external invocation.
- Extend ConversationManager (Plugin) instead of implementing HookProvider
- Replace registerCallbacks with initAgent/reduce pattern
- Add super() call in constructor
- Update tests to use Plugin interface and mock agent tracked hooks

---
Prompt: review the tests and fix them
@jsamuel1 jsamuel1 force-pushed the feat/summarizing-conversation-manager branch from 2466cf8 to 87297cd Compare March 22, 2026 07:44
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