mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
feat: create checkpoints before context compression
- Add checkpoint save before manual context compression in condenseContext method - Add checkpoint save before automatic context compression in attemptApiRequest method - Use force=true to ensure checkpoint even without file changes - Use suppressMessage=true for cleaner UI experience Fixes #9334
This commit is contained in:
parent
dbaaef756e
commit
bd7175a11e
1 changed files with 18 additions and 0 deletions
|
|
@ -1074,6 +1074,12 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
}
|
||||
|
||||
public async condenseContext(): Promise<void> {
|
||||
// Create a checkpoint before context compression to allow reverting if needed
|
||||
// Use force=true to ensure checkpoint even if no file changes, and suppress message for cleaner UI
|
||||
if (this.enableCheckpoints) {
|
||||
await this.checkpointSave(true, true)
|
||||
}
|
||||
|
||||
const systemPrompt = await this.getSystemPrompt()
|
||||
|
||||
// Get condensing configuration
|
||||
|
|
@ -2952,6 +2958,18 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
// Get the current profile ID using the helper method
|
||||
const currentProfileId = this.getCurrentProfileId(state)
|
||||
|
||||
// Create a checkpoint before automatic context compression to allow reverting if needed
|
||||
// Only create checkpoint if compression might actually happen
|
||||
const contextPercent = (100 * contextTokens) / contextWindow
|
||||
if (
|
||||
autoCondenseContext &&
|
||||
(contextPercent >= autoCondenseContextPercent || contextTokens > contextWindow * 0.9 - (maxTokens || 0))
|
||||
) {
|
||||
if (this.enableCheckpoints) {
|
||||
await this.checkpointSave(true, true)
|
||||
}
|
||||
}
|
||||
|
||||
const truncateResult = await manageContext({
|
||||
messages: this.apiConversationHistory,
|
||||
totalTokens: contextTokens,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue