Why AI Coding Agents Fail: The Critical Gap Between Files and Lines

While AI coding agents are increasingly capable of resolving software bugs, a new study reveals they suffer from a significant "localization" problem. They can navigate to the correct file within a massive codebase, but they frequently fail to identify the specific lines of code required to implement a fix.

Introducing SWE-Explore: Moving Beyond Repair Rates

Historically, the effectiveness of AI coding agents has been measured by a single, binary metric: did the agent fix the bug or not? This approach ignores the "why" behind a failure. A failed repair could mean the agent wrote a bad patch, or it could mean the agent never even looked at the relevant logic.

To address this blind spot, an international research team, including scientists from Shanghai Jiao Tong University, developed SWE-Explore. Unlike traditional benchmarks, SWE-Explore isolates the upstream search phase. It evaluates an agent's ability to take a bug description and return a ranked list of the specific code sections that are actually relevant to the problem. The dataset is extensive, drawing from 848 tasks across 203 open-source projects and ten programming languages, with Python being the most prominent (547 tasks).

The Precision Gap: File Success vs. Line Failure

The study’s most striking finding is the massive disparity between file-level and line-level accuracy. When tested against general-purpose agents like Claude Code, Codex, and OpenHands, the results were telling:

  • File-level accuracy: Agents perform well, successfully identifying the correct source files and ranking them highly.
  • Line-level accuracy: Performance collapses. General coding agents covered only 14% to 19% of the actual lines of code that mattered for a fix.

Interestingly, simply upgrading the underlying Large Language Model (LLM) does not solve this. Whether using models from OpenAI, Anthropic, Google, Moonshot, or Zhipu, the pattern remains identical: high file hit rates but abysmal line coverage. The research noted that specialized systems like CoSIL outperformed general agents by treating code as a network of interconnected building blocks, suggesting that architectural changes are more important than raw model power.

The Threshold Effect: Why "Reading More" Matters

کنٹرول شدہ ایبلیشن تجربات کے ذریعے، محققین نے کانٹیکسٹ کے حوالے سے ایک "تھریش ہول ایفیکٹ" دریافت کیا۔ ماڈل کو فراہم کیے گئے بنیادی کوڈ کی مقدار میں تبدیلی (0% سے 100% تک) کے ذریعے، انہوں نے پایا کہ اصلاحات (repairs) لکیری طور پر بہتر نہیں ہوتی ہیں۔

آسان کاموں کے لیے، ایک واضح ٹپنگ پوائنٹ موجود ہے: اگر کوئی ایجنٹ ضروری بنیادی حصوں کے 50% سے کم حصے کو دیکھتا ہے، تو اصلاح کی کامیابی کی شرح صفر کے قریب رہتی ہے۔ کامیاب اصلاحات میں نمایاں اضافہ تب ہی ہوتا ہے جب ایجنٹ کو مطلوبہ کانٹیکسٹ کے 50% سے 75% تک رسائی حاصل ہو۔ اہم بات یہ ہے کہ مطالعے میں یہ پایا گیا کہ غیر متعلقہ "شور" (noise) والا کوڈ فراہم کرنے سے کارکردگی پر اتنا برا اثر نہیں پڑتا جتنا کہ اہم لائنوں کے غائب ہونے سے پڑتا ہے۔ ڈویلپرز کے لیے حاصل شدہ نتیجہ واضح ہے: AI ایجنٹس کے دور میں، ضروری تفصیلات کو فلٹر کرنے کا خطرہ مول لینے کے بجائے زیادہ کانٹیکسٹ فراہم کرنا بہتر ہے۔

اہم نکات

  • لوکلائزیشن (Localization) ایک رکاوٹ ہے: AI ایجنٹس صحیح فائل تلاش کرنے میں ماہر ہیں لیکن اصلاح کے لیے درکار کوڈ کی مخصوص لائنوں کی درست نشاندہی کرنے میں انہیں کافی مشکلات کا سامنا کرنا پڑتا ہے۔
  • ماڈل اسکیلنگ کوئی جادوئی حل نہیں ہے: زیادہ طاقتور LLMs پر اپ گریڈ کرنے سے لائن کی سطح پر درستگی کا فرق ختم نہیں ہوتا؛ CoSIL جیسے مخصوص طرزِ تعمیراتی طریقے زیادہ مؤثر ہیں۔
  • 50% کانٹیکسٹ کا اصول: AI اصلاح کی کامیابی ایک تھریش ہول پیٹرن کی پیروی کرتی ہے، جس میں کامیاب اصلاحات کے ممکن ہونے سے پہلے متعلقہ کوڈ کانٹیکسٹ کے کم از کم 50-75% حصے کا نظر آنا ضروری ہے۔