TL;DR
This paper introduces a novel framework to supercharge LLM-based code reviews by shifting from predicting a single "primary" issue to generating a comprehensive "issue-list." By augmenting the LLM's prompt with targeted local, semantic, and structural code context, and then pruning redundant suggestions using simulated code changes, the approach achieves a massive +10.85 percentage point boost in generating human-aligned review comments.
What Problem Does This Paper Address?
Most automated code review tools try to mimic human reviewers by pointing out the single most critical issue in a code snippet (primary-issue review). However, large language models (LLMs) often prioritize code issues differently than humans. If an LLM identifies a valid bug but deems a generic defensive-programming suggestion more "important," the actual bug gets omitted entirely.
Furthermore, looking at a isolated code change (a diff hunk) doesn't provide enough information. To spot deep architectural flaws or API mismatches, a reviewer needs broader context: What does this called function actually do? How are other files in this pull request handling similar logic?
The authors tackle two main challenges:
- How to help LLMs comprehensively discover and prioritize the right code review issues.
- How to feed the LLM the right context without overwhelming its context window or distracting it with irrelevant code.
Methods
The authors propose a three-stage approach to optimize LLM code reviews:
- Issue-List Review Paradigm: Instead of forcing the LLM to output one primary comment, they prompt it to act as a comprehensive reviewer, utilizing a structured taxonomy of code review issues (Functional vs. Refactoring defects) to list and rank all potential issues.
- Context Augmentation: They systematically extract and test three types of context beyond the local diff hunk:
- Function-Level Neighboring Context: The enclosing function body to understand local data/control flow.
- LSP-Based Semantic Context: Leveraging the Language Server Protocol (
getDefinition,getReferences) to pull in exact type definitions and usage sites of modified identifiers. - IR-Based Similar Co-Change Context: Using information retrieval (TF-IDF similarity) to extract similar code patterns from other files modified within the same commit.
- Refinement-Guided Pruning: Merging no-context and context-enhanced suggestions can lead to a massive list of comments, causing developer fatigue. To solve this, the authors use an auxiliary model (
CodeReviewer) to simulate the exact code change each comment would induce. If a comment triggers no code change or results in a duplicate change already covered by a higher-ranked comment, it is pruned.
Datasets
The approach was evaluated on 1,438 Go review instances reconstructed from the public CodeReviewer benchmark. The authors specifically chose Go because its strong static typing allows for highly reliable symbol resolution via LSP without the heavy build-tool configurations required by languages like Java.
Key Insights and Ideas
- The Prioritization Bottleneck: LLMs are often fully capable of identifying the correct human-aligned issue, but they bury or omit it when constrained to a single output. Shifting to an issue-list format unlocks this latent capability.
- More Context $\neq$ Better Performance: Blindly dumping all available context types into the prompt actually degrades performance. For example, adding semantic context on top of neighboring and co-change context diluted the key signals, causing the model to miss bugs it previously caught. Selective context is key.
- Action-Grounded Evaluation: Evaluating code review comments based on text similarity (like BLEU scores) is notoriously unreliable. Instead, this paper evaluates comments by their downstream code refinement impact—measuring how often a comment successfully guides an automated model to generate an exact match of the final human code revision.
Key Results
- Massive Performance Gains: The best configuration (combining issue-list review, neighboring context, and similar co-change context) achieved 28.00% Refinement Exact Match (RefineEM). This is a +10.85 percentage point improvement over the standard no-context primary-issue baseline (17.15%).
- Outperforming Baselines: The framework substantially outperformed
CodeReviewer(15.02%), a specialized model trained specifically for code reviews, and closed the gap toward the human-oracle ceiling of 36.09%. - Highly Effective Pruning: The refinement-guided pruning strategy successfully slashed the average number of candidate comments from 7.2 down to 3.1 at top-5 while retaining 99.6% of the full-list performance, making the final output highly practical for real-world developers.
Limitations and Future Work
- Language Constraints: The study is restricted to Go. Languages with dynamic typing (like Python) might introduce ambiguity during LSP symbol resolution, potentially reducing the efficacy of semantic context retrieval.
- Single LLM Evaluation: The pipeline was evaluated exclusively using DeepSeek-V3.
- Retrieval Scope: Similar co-change context retrieval was limited to files within the same commit. Expanding this to a repository-wide search could surface more patterns but risks introducing substantial noise.
- Future Directions: The authors suggest exploring multi-agent architectures where independent sub-agents handle different context configurations and jointly deliberate on conflicting signals.
Summary updated