Skip to content

feat: Implement Smart Incremental Reviews to Reduce Token Usage and Improve UX #40

@nfebe

Description

@nfebe

Problem

Current review system is inefficient:

  • Re-reviews entire PR on each push (wastes 60-80% of tokens)
  • Reviews trivial changes (formatting, imports, lockfiles)
  • Provides redundant feedback on unchanged code
  • Poor developer experience with repeated suggestions

Solution

Implement smart incremental reviews with two modes:

Stateless Mode (No DB required)

  • File filtering: Skip auto-generated files, lockfiles, trivial formatting changes
  • Change classification: Detect meaningful vs cosmetic changes using patterns
  • Commit analysis: Parse commit messages for change context
  • Expected savings: 30-50% token reduction

Stateful Mode (Database enabled)

  • Incremental diffs: Only review changes since last review (git diff last_sha..head_sha)
  • Suggestion tracking: Store and deduplicate previous suggestions
  • Review state: Track last reviewed SHA per PR
  • Expected savings: 60-80% token reduction

Implementation

Phase 1 (Low risk): Stateless improvements

Skip these file patterns

SKIP_FILES = ['.lock', 'package-lock.json', 'yarn.lock']
TRIVIAL_PATTERNS = [r'^\s
$', r'^(import|from)\s+', r'^\s*(#|//)']

Phase 2: Stateful improvements

  • Add ReviewState model to track last reviewed SHA
  • Add ReviewSuggestionHistory for deduplication
  • Modify dispatcher to use incremental diffs

Benefits

  • Cost reduction: 30-80% fewer tokens used
  • Faster reviews: Skip processing trivial files
  • Better UX: No redundant suggestions for unchanged code
  • Backwards compatible: Opt-in via config flags

Configuration

ENABLE_SMART_FILTERING=true
ENABLE_INCREMENTAL_REVIEWS=true # stateful only
TRIVIAL_CHANGE_THRESHOLD=3

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions