Skip to content

feat: add file deduplication to reduce token usage #2

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

Closed
wants to merge 3 commits into from

Conversation

MuriloFP
Copy link
Owner

@MuriloFP MuriloFP commented Jul 7, 2025

Re-implements PR RooCodeInc#1374 functionality on current codebase structure

Overview

This PR re-implements the file deduplication feature originally proposed in PR RooCodeInc#1374. The original PR had significant merge conflicts and was based on an older codebase structure. This implementation provides the same functionality but integrated with the current architecture.

Changes

  • Added deduplicateReadFileHistory() method to Task.ts that removes duplicate file reads from conversation history
  • Implemented smart deduplication that:
    • Preserves the most recent read of each file
    • Handles partial file reads (line ranges) correctly
    • Preserves @mention file content
    • Only deduplicates within the current task's messages
  • Made the feature configurable via contextDeduplication experiment flag (disabled by default)
  • Added comprehensive test coverage for all deduplication scenarios

Key Improvements Over Original PR

  1. Partial Read Support: Correctly handles files read with line ranges
  2. @mention Preservation: Keeps user-provided file content intact
  3. Configurable: Feature can be toggled via experiment flag
  4. Better Integration: Works with the refactored Task.ts structure
  5. Comprehensive Testing: Full test coverage for all scenarios

Testing

All new tests pass and the feature has been validated to work correctly with:

  • Basic deduplication of repeated full file reads
  • Handling of partial file reads with line ranges
  • Preservation of @mention file content
  • Multiple file deduplication
  • Edge cases (empty history, no duplicates)

Closes RooCodeInc#1374

MuriloFP added 3 commits July 7, 2025 18:05
- Implement deduplicateReadFileHistory() method in Task.ts
- Add support for partial file reads with line ranges
- Preserve @mention file content from deduplication
- Make feature configurable via deduplicateReadFiles experiment flag
- Add comprehensive test coverage for all deduplication scenarios

Re-implements PR RooCodeInc#1374 functionality on current codebase structure
@KJ7LNW
Copy link

KJ7LNW commented Jul 22, 2025

see also: RooCodeInc#6053 prevents duplicate reads all together.

@MuriloFP MuriloFP closed this Jul 22, 2025
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.

2 participants