-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add Context Synthesization Feature #3017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements the optional context summarization feature based on the plan in (now deleted) `context-summarization-plan.md`. Key changes: - Adds new settings (`enableContextSummarization`, thresholds, turn counts) to control the feature, accessible in Settings -> Context Management. Settings are persistent and included in import/export. - Creates `ContextSummarizer` service to handle summarization logic, using the main configured LLM with a refined, directive prompt. - Modifies `Cline.ts` to conditionally call the summarizer or fallback to truncation based on settings and token thresholds before API requests. - Adds a system message `[Older conversation turns summarized...]` to the chat UI for transparency when summarization occurs. - Includes necessary updates to schemas, types, message handlers, webview context, and tests. - Fixes UI state bugs related to settings persistence and interaction.
|
|
The pull request is quite large, with 39 changed files and 1239 lines added. While the changes primarily focus on adding context summarization features, there are also updates to settings and tests. It might be beneficial to split the pull request into smaller, more manageable parts. Consider separating the context summarization feature implementation from the settings updates and tests. This will make it easier to review and ensure each part is thoroughly tested and validated. |
| await updateGlobalState("historyPreviewCollapsed", message.bool ?? false) | ||
| // No need to call postStateToWebview here as the UI already updated optimistically | ||
| break | ||
| // Context Synthesization Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an inconsistent use of terminology for the context feature. The comments mention 'Context Synthesization Settings', but the state keys and message cases use 'Context Summarization' (e.g., 'enableContextSummarization', 'manualSynthesize'). Consider standardizing the terminology across the code for clarity.
| // Context Synthesization Settings | |
| // Context Summarization Settings |
This comment was generated because it violated a code review rule: mrule_aQsEnH8jWdOfHq2Z.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do need to unify terminology
| | "searchFiles" | ||
| | "toggleApiConfigPin" | ||
| | "setHistoryPreviewCollapsed" | ||
| // Context Synthesizing Settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an inconsistency in the naming conventions for the context synthesization/summarization settings. The comment above the new union values says "Context Synthesizing Settings" while the union type options use "ContextSummarization..." (e.g., enableContextSummarization, contextSummarizationTriggerThreshold) along with "manualSynthesize" and "synthesizationStatus". Consider using a consistent term (either 'synthesization' or 'summarization') for clarity and to avoid confusion.
| // Context Synthesizing Settings | |
| // Context Summarization Settings |
This comment was generated because it violated a code review rule: mrule_aQsEnH8jWdOfHq2Z.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
| onChange={(e: any) => setCachedStateField("enableContextSummarization", e.target.checked)} // Use generic setter | ||
| data-testid="enable-context-summarization-checkbox"> | ||
| <label className="block font-medium mb-1"> | ||
| {t("settings:contextManagement.synthesization.enable.label")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a naming inconsistency: the component and props refer to 'Context Summarization' while the translation keys use 'synthesization' (e.g. t("settings:contextManagement.synthesization.enable.label")). It would be clearer if a single term was chosen for consistency throughout the codebase.
This comment was generated because it violated a code review rule: mrule_aQsEnH8jWdOfHq2Z.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
| mcpServers: McpServer[] | ||
| hasSystemPromptOverride?: boolean | ||
| currentCheckpoint?: string | ||
| synthesizationStatus?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an inconsistency in naming: the state property is named synthesizationStatus (with an 'i') while the default settings and setters use ...Summarization... (with an 'a'). Please standardize the terminology (either use 'synthesization' or 'summarization') to avoid confusion.
This comment was generated because it violated a code review rule: mrule_aQsEnH8jWdOfHq2Z.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
| "label": "Torns recents a mantenir", | ||
| "description": "Nombre dels missatges de conversa més recents a mantenir sempre amb detall complet." | ||
| }, | ||
| "turns": "missatges" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor lexicographical inconsistency: In the 'summarization' block, the key 'turns' is labeled as "missatges", which contrasts with the use of "Torns" in the 'initialTurns' and 'recentTurns' keys. Consider using a consistent term (e.g., "torns") for conversation turns to avoid confusion.
| "turns": "missatges" | |
| "turns": "torns" |
|
Nice. My Venmo is open for naming rights :-) |
haha! the cost of rebranding ..! i think i need to fix some tests too |
|
This needs to have another update, currently disabling auto synthesize stops the manual @ mention also. |
|
its fixed now. |
|
@shariqriazz - Thanks so much for getting the ball rolling on this. We're discussing internally what the strategy should be for this class of feature (also related: #2971). We're going to figure it out for next week's release. |
|
@cte Perfect, looking forward for this |
|
Thanks for the inspiration here! We added some version of this in #3582, which you can enable with the |
|
@shariqriazz The primary concern with your PR was the large surface area and complexity of the changes relative to what the feature actually delivered. Your implementation introduced a significant amount of risk and potential technical debt. Another PR was merged because it achieved the same functionality but with a smaller, more manageable footprint and less complexity. Sorry for not working more closely with you on this earlier on to help get this across the finish line. We really do appreciate everything you done on this. |
Overview
This feature introduces intelligent context management through synthesization, significantly enhancing Roo Code's ability to maintain conversation coherence during extended interactions. Unlike the existing sliding window approach that simply truncates conversations, context synthesization uses AI to create concise summaries of conversation history, preserving critical information while reducing token usage.
Key Features
Automatic Context Synthesization
Manual Context Synthesization
User Configuration
Comparison with Sliding Window
Technical Implementation
Core Components
ContextSynthesizer Service
Integration with Conversation Flow
UI Components
Key Differences from Sliding Window
The sliding window implementation (
src/core/sliding-window/index.ts) uses a simple truncation approach:In contrast, the new synthesization approach (
src/services/synthesization/ContextSynthesizer.ts) uses AI to create an intelligent summary:Benefits
Use Cases
Future Enhancements
Important
This pull request adds a context synthesization feature to summarize older conversation turns, with both automatic and manual triggers, configurable settings, and integration into the conversation flow and UI components.
ContextSynthesizerservice insrc/services/synthesization/ContextSynthesizer.tsfor AI-powered synthesis.Cline.tsto integrate synthesization with conversation flow.SynthesizingIndicatorand context menu options for manual triggering.ClineProvider.tsandwebviewMessageHandler.tsto handle new settings and manual synthesization messages.ClineProvider.test.tsfor context summarization settings.This description was created by
for 115efcc. You can customize this summary. It will automatically update as commits are pushed.