feat(SDK): Integrate context summarization with conversation memory BZ-43344 - #89
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughRemoves the legacy ContextManager and its configs/types/utilities. Introduces turn-based conversation summarization integrated into ConversationMemoryManager and conversationMemory config. Updates docs to reflect constructor-based activation, session scoping, and new addMCPServer API. Adjusts utils/config/types to support summarization; cleans neurolink.ts of enableContextSummarization. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant NeuroLink
participant ConversationMemoryManager as ConvMemory
participant Summarizer as NeuroLink(summarize)
Client->>NeuroLink: generate({ input, context.sessionId })
NeuroLink->>ConvMemory: storeConversationTurn(sessionId, user/assistant)
alt Summarization enabled & threshold exceeded
ConvMemory->>Summarizer: generate(summary prompt, provider/model)
Summarizer-->>ConvMemory: summary text
ConvMemory->>ConvMemory: replace older history with system(summary) + recent turns
else Below threshold
ConvMemory->>ConvMemory: keep history, enforce limits
end
NeuroLink->>ConvMemory: buildContextMessages(sessionId)
ConvMemory-->>NeuroLink: messages (possibly with system summary)
NeuroLink-->>Client: generate result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
466cc61 to
3b222c8
Compare
3b222c8 to
995f62f
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR integrates automatic context summarization functionality into the existing conversation memory system. The change replaces a standalone context management approach with a unified system that manages conversation history and summarization within the ConversationMemoryManager.
- Removes the legacy
enableContextSummarizationmethod and relatedContextManagerclass - Integrates summarization logic directly into
ConversationMemoryManagerwith proper turn-based ordering - Configures summarization through the existing
conversationMemoryconstructor option
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/utils/conversationMemoryUtils.ts | Adds summarization logic and helper functions to conversation memory utilities |
| src/lib/types/generateTypes.ts | Removes unused import of deprecated ContextManagerConfig |
| src/lib/types/conversationTypes.ts | Extends ConversationMemoryConfig with summarization options |
| src/lib/neurolink.ts | Removes deprecated enableContextSummarization method and related context manager code |
| src/lib/core/types.ts | Adds conversationMemoryConfig to TextGenerationOptions |
| src/lib/core/conversationMemoryManager.ts | Integrates summarization logic with proper turn-based ordering and refactors methods |
| src/lib/context/* | Removes deprecated context management files |
| src/lib/config/conversationMemoryConfig.ts | Adds environment variable support for summarization configuration |
| memory-bank/* | Updates documentation to reflect new integrated approach |
| docs/* | Updates API documentation and guides for the new unified system |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
cb443df to
d3701cb
Compare
ca4727a to
ee2b428
Compare
ee2b428 to
904a4e7
Compare
Pull Request
Description
This PR integrates a new Automatic Context Summarization feature into the existing Conversation Memory system. This enhancement allows the SDK to automatically summarize long-running conversations, preventing context overflow errors while preserving key information.
The summarization logic hooks into the conversation memory lifecycle, triggering before the standard turn-based truncation to ensure a more intelligent context management strategy.
Type of Change
Related Issues
Changes Made
Integrated Summarization into Conversation Memory: The summarization logic is now part of the
ConversationMemoryManager, activated by a newenableSummarizationflag in theconversationMemoryconfig.Corrected Order of Operations: The manager now adds a new turn, checks for summarization, and then performs truncation, fixing a race condition that caused premature context loss.
Configuration via Constructor: The feature is configured through the existing
conversationMemoryobject in theNeuroLinkconstructor.Recursion-Safe Design: The summarization call uses a new, memory-disabled
NeuroLinkinstance to prevent infinite loops.Documentation Updated: All relevant documentation has been updated to reflect the new integrated feature.
AI Provider Impact
Component Impact
Testing
Test Environment
Performance Impact
Breaking Changes
None. The feature is opt-in through the existing conversationMemory configuration and does not change any public APIs.
Screenshots/Demo
Checklist
Additional Notes
Summary by CodeRabbit
New Features
Refactor
Documentation