Diffs Are Cheap, Show Me the Trajectory: An Empirical Study of Trajectory-Informed Code Review

Zijian Luo, Pengfei Gao, Dayi Lin, Zhiyu Fan, Yongqiang Tian, Alejandro Carderera de Diego, Judge Hiciano, Gemma Garriga, Qingwei Lin, Dongmei ZhangarXiv 2026

TL;DR

When reviewing code, we usually just look at the final "diff"—the clean end product. When AI coding agents write code, however, they leave behind a rich lab notebook of false starts, assumptions, and failed tests called a trajectory. This paper shows that giving independent AI reviewers structured access to these development trajectories significantly boosts their ability to catch bugs—though how you package that messy history matters just as much as having it.

What Problem Does This Paper Address?

Imagine grading a complex math proof where you only see the final equation, with all the scratch paper burned. That’s standard code review: you inspect the final patch (diff) and surrounding repository, missing the messy reality of discarded ideas, silent assumptions, and edge cases patched in haste.

Unlike human developers whose thought processes stay mostly in their heads, AI coding agents think out loud. Their development trajectories record every prompt, internal plan, search, edit, and test failure. In theory, if an agent says, "I assume this new shortcut still triggers custom user hooks," a reviewer has a golden lead to verify. In practice, trajectories are bloated with thousands of lines of noisy terminal outputs and dead-end code. Does handing this raw log to an independent AI reviewer actually help catch bugs, or just drown it in noise?

Table 1. Development trajectory contents and their potential review uses.

Methods

To test trajectory-informed code review, the authors separated code generation from review—having independent AI review harnesses (Codex CLI and GitHub Copilot CLI, powered by GPT-5.6 Sol) inspect patches created by separate coding agents.

Fig. 1. Dataset construction and trajectory-informed review workflow.

Beyond comparing standard Diff-only review against raw Full-trajectory access, the team designed four structured ways to present and use trajectory data:

  • Messages: Strips out noisy tool calls and terminal logs, keeping only the chronological text of the user request and agent thoughts/claims.
  • Self-selected signals: Before looking at the code, the reviewer reads the trajectory and freely takes notes on what seems worth checking.
  • Evidence-linked map: A coordinator builds a strict, structured map of facts and prioritized test questions citing specific trajectory events before code inspection, capping investigation at ten focused probes.
  • Code-first adversarial scrutiny: The reviewer inspects the code first to form an unbiased opinion, then reads the trajectory specifically to challenge the coding agent's safety claims and test coverage.

Because public agent trajectories rarely have thorough human code reviews attached, the authors also invented a clever synthetic benchmark generator: an LLM compares an initial flawed patch against a ground-truth final patch to reverse-engineer the exact review comments needed to bridge the gap.

Datasets

  • Human-PR Validation Corpus: 100 human-authored GitHub pull requests (from 49 popular MIT-licensed repositories) containing 126 real human review comments. Used to validate their synthetic comment generator.
  • Trajectory-Linked Review Dataset (New): Built on 113 DeepSWE tasks across 91 repositories (spanning Go, Python, TypeScript, JavaScript, and Rust). Running three coding agents (GPT-5.5, GPT-5.6 Sol, and Gemini 3.8 Flash) yielded 339 implementations paired with full trajectories and 882 synthetic reference review comments.

Key Insights and Ideas

  • Raw logs go unread: Simply giving an agent tool access to the full trajectory isn't a silver bullet. Reviewers queried only about 10% of the raw trajectory text, and performance actually dropped in two configurations.
  • Just reading the "diary" is wildly effective: The Messages view—which throws away all tool executions and test logs, keeping only the agent’s narrative—came in a close second overall while using fewer tokens across every single configuration. Knowing what the coder assumed gives the reviewer tremendous leverage.
  • Trajectories change what you find, not just how much: Trajectory-informed review and diff-only review catch different bugs. Even the best trajectory method missed bugs that a plain diff-only pass caught, suggesting process history and pure code inspection are complementary lenses.

Key Results

  • Validating synthetic references: On the 100 human PRs, the authors' comment-generation method recovered 81.22% of withheld human review concerns (with 100.00% micro precision and 89.62% F1).
  • Full-trajectory vs. Diff-only: Raw trajectory access bumped mean reference recall (the percentage of known issues caught) from 23.03% to 25.87% (+2.83 percentage points), improving 4 of 6 configurations.
  • Structured trajectory methods win: All four structured approaches beat both diff-only and raw trajectories across the board (+4.05 to +7.32 pp over diff-only). Evidence-linked map led at 30.35% mean recall, followed closely by Messages at 29.03%, Self-selected signals (27.83%), and Adversarial scrutiny (27.08%).
  • Critical failures & cost: All four structured methods improved recall on critical review comments explaining task-verifier failures, though higher recall can demand more tokens and longer review times.

Limitations and Future Work

While the provided text cuts off before the formal Discussion section, several boundaries are clear from the study design and abstract:

  • Synthetic ground truth: Because real-world agent PRs lacked dense human feedback, main evaluations rely on synthetic comments derived from held-out reference solutions rather than live human reviewers.
  • Recall over precision: The primary metric (micro recall) measures how many reference bugs the reviewer caught, rather than grading the accuracy or false-positive rate of every extra comment the reviewer generated.
  • Cost-coverage trade-offs: Structured methods like the evidence-linked map boost defect discovery but consume extra tokens and time, pointing toward future work in lightweight, high-signal trajectory views (like Messages) or hybrid diff-plus-trajectory workflows.

Summary updated

Abstract

Code review typically starts from the final diff. However, the diff reveals little about how the code was developed. Coding-agent trajectories preserve intermediate decisions, failed attempts, and validation evidence that may assist code review. We systematically investigate whether and how these trajectories can help independent review agents identify problems in the resulting code, beyond inspecting the final diff and repository. We develop a procedure that generates review comments by comparing the initial and merged versions of pull requests, and assess it against withheld human review comments. Using held-out reference implementations as comparison targets for agent-produced code, we construct a dataset linking 339 implementations of 113 DeepSWE tasks with their trajectories and 882 synthetic reference review comments. Across three coding-agent configurations and two review harnesses, we compare diff-only review, full-trajectory access, and four alternative ways of presenting and using trajectories. Full-trajectory access raises mean reference recall from 23.03% to 25.87%, but improves recall in only four of six configurations. All four alternatives improve mean reference recall over diff-only by between 4.05 and 7.32 percentage points. The gains also extend to review comments that explain task-verifier failures. Higher recall can require more tokens and longer review time, while simpler trajectory views remain competitive. These results support development trajectories as an additional source of code-review context and show that their benefits and resource costs depend on how they are presented and used.
BibTeX
@misc{luo2026diffs,
  author = {Zijian Luo and Pengfei Gao and Dayi Lin and Zhiyu Fan and Yongqiang Tian and Alejandro Carderera de Diego and Judge Hiciano and Gemma Garriga and Qingwei Lin and Dongmei Zhang},
  title = {{Diffs Are Cheap, Show Me the Trajectory: An Empirical Study of Trajectory-Informed Code Review}},
  year = {2026},
  eprint = {2611.31316},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.31316},
}
Figure