cs.SEMar 25, 2026

Coherence Collapse: Diagnosing Why Code Agents Fail After Reaching the Right Code

Authors: Myeongsoo Kim, Dingmin Wang, Siwei Cui, Farima Farmahinifarahani, Terry Yue Zhuo, Shweta Garg, Baishakhi Ray, Rajdeep Mukherjee, 

Organizations: AWS AI Labs · Monash University

Abstract

Code agents resolve 65-70% of SWE-bench Verified issues, but Pass@1 cannot tell us why the rest fail, and, as we show, capable-model failures are systematically misdiagnosed without trajectory data. We introduce TRAJEVAL, a training-free decomposition of agent trajectories into reference-patch-aligned search, read, and edit stages, and apply it across 16,758 trajectories spanning three architectures and seven models. The dominant failure of capable models is not localization: 60-69% of failures on SWE-Agent and OpenHands reach and edit the correct functions yet still produce incorrect patches, and the pattern persists for most models on the bash-only LiveSWEAgent. Within this Edit-Quality residual, we identify Coherence Collapse, where the agent reaches correct code and then overwrites or thrashes it, as the largest theme, replicating across SWE-bench Verified and the multilingual PolyBench Verified. In 5 cases, the agent produces a patch bit-identical to the gold reference mid-trajectory and destroys it later; an edit-commit checkpoint recovers all 5 against the SWE-bench Docker harness. A reference-free consensus-driven variant yields a directional +3.0 pp Pass@1 measurement on GPT-5 (p=0.08).

Figures & tables

Appendix figures & tables31 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Teaching Agents to Code Reliably

    Oct 2, 2026Muhammad Ahmed Mohsin, Myeongsoo Kim, Kangrui Ruan +3Repository-Level Program RepairAI Coding Agents

  2. FailForge: Distilling Procedural Competence from Persistent Failures into Code Agents

    Aug 9, 2026Dongyi Lv, Fushun E, Aichen Cai +8Fine-TuningSoftware Engineering Agents

  3. CodeTracer: Towards Traceable Agent States

    Apr 13, 2026Han Li, Yifan Yao, Letian Zhu +13AI Coding AgentsAgent Trajectory Analysis