Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Nov 17, 2025

Summary

This PR attempts to address Issue #9308. When context compression occurs (either manually or automatically), the checkpoint system now preserves the full API conversation history alongside file checkpoints, allowing users to restore to the pre-compression state.

Problem

Previously, when context was compressed, the API conversation history was permanently modified. Restoring checkpoints would only restore file changes but not the conversation state, leaving users stuck with compressed context even when rolling back to earlier checkpoints.

Solution

  1. API History Snapshots: Save the complete API conversation history alongside each checkpoint
  2. Restore Full History: When restoring a checkpoint, also restore the associated API conversation history
  3. Automatic Checkpoints: Create checkpoints automatically before context compression operations to preserve the full conversation

Changes

  • Added saveApiHistorySnapshot() and restoreApiHistorySnapshot() methods to the checkpoint service
  • Modified checkpoint save to include API history snapshots
  • Modified checkpoint restore to restore API history when available (falls back to old behavior for existing checkpoints)
  • Added automatic checkpoint creation before context compression operations
  • Added comprehensive test coverage for the new functionality

Testing

  • All existing checkpoint tests pass
  • New tests added specifically for API history snapshot functionality
  • Manual testing confirms that restoring checkpoints now properly restores pre-compression conversation state

Fixes #9308

Feedback and guidance are welcome!


Important

This PR enhances the checkpoint system to save and restore full API conversation history, ensuring restoration of pre-compression states.

  • Behavior:
    • Checkpoints now save and restore full API conversation history, preserving pre-compression state.
    • Automatic checkpoints created before context compression operations.
  • Functions:
    • Adds saveApiHistorySnapshot() and restoreApiHistorySnapshot() to ShadowCheckpointService.
    • Modifies checkpointSave() and checkpointRestore() in index.ts to handle API history snapshots.
  • Testing:
    • New tests in api-snapshots.spec.ts for API history snapshot functionality.
    • Updates to checkpoint.test.ts to mock new methods and test fallback behavior.

This description was created by Ellipsis for 5b4dedb. You can customize this summary. It will automatically update as commits are pushed.

…fore context compression

- Save API conversation history snapshots along with file checkpoints
- Restore full API history when reverting to checkpoints made before compression
- Automatically create checkpoint before context compression operations
- Add comprehensive tests for API history snapshot functionality

Fixes #9308
@roomote roomote bot requested review from cte, jr and mrubens as code owners November 17, 2025 16:16
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Nov 17, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Nov 17, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed. Found 1 issue that should be addressed:

  • API history snapshot timing issue: The snapshot is saved after the checkpoint result is returned, but may be skipped if no file changes occurred. This could lead to inconsistent state where some checkpoints have snapshots and others don't.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines +230 to +238
// Save API conversation history snapshot along with checkpoint
if (checkpointResult && checkpointResult.commit) {
try {
await service.saveApiHistorySnapshot(checkpointResult.commit, task.apiConversationHistory)
} catch (err) {
console.error("[Task#checkpointSave] Failed to save API history snapshot:", err)
// Don't disable checkpoints for this error, continue with file checkpoint only
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The API history snapshot is saved after awaiting the checkpoint result, but if checkpointResult is undefined (when saveCheckpoint returns undefined for no changes), the snapshot save will be skipped. This could lead to inconsistent state where some checkpoints have snapshots and others don't, even when the API history should be preserved. Consider saving the snapshot before returning, or ensure it's saved even when no file changes occurred but API history exists.

Fix it with Roo Code or mention @roomote and request a fix.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Context compression is permanent? Checkpoints don't help?

3 participants