Developer tools · Research feature

Study Tests AI Models on Real-World Software Code Understanding Across Entire Repositories

A new study evaluates large language models on repository-level software question answering using real developer queries from open-source Java projects.

Adapted from research by Yoseph Berhanu Alebachew, Hunter Leary, Swanand Vaishampayan and colleagues.

arXiv preprint revision · 2026-04-04 · Attribution & reuse
In this article
Editorial illustration of stacked plates.

Editor’s introduction

The study assesses two LLMs—Claude 3.5 Sonnet and GPT-4o—on a dataset of 1,318 developer questions drawn from 134 open-source Java projects. This is the first empirical work to document such patterns in repository-scale QA. The study is limited to Java projects, may not reflect industrial or private repository challenges, and evaluates only specific augmentation strategies, leaving room for alternative approaches. Findings suggest current LLMs lack sufficient reasoning capacity for full repository comprehension and require structured retrieval and verification to be reliable in real-world settings.

Introduction

Program comprehension is a critical process for developing and maintaining software systems. However, modern codebases11 1 In this paper we use the terms ‘project’, ‘codebase’, and ‘repository’ interchangeably to refer to the entirety of the codebase as opposed to a single file or snippet. are often too complex for developers to easily understand. As a result, comprehension is one of the most time-consuming aspects of software development. Studies estimate that professional developers spend about 58% of their time trying to understand existing codebases.

Compared to documentation—which is often outdated or poorly maintained—developers frequently perceive these social resources as more useful, timely, and reliable. However, maintaining question answering (QA) platforms is resource-intensive, and many questions remain unanswered or answers quickly become outdated as the underlying code evolves. This also slows open-source contributions, as potential contributors may not receive timely guidance when maintainers are overloaded.

Recent developments in Large Language Models (LLMs) show strong potential for a wide range of software engineering (SE) tasks, including program comprehension and QA. By pretraining on vast internet-scale corpora, LLMs are rapidly becoming integral to developer workflows. Consequently, developers are increasingly using LLMs to answer questions they would have previously directed to peers or platforms like Stack Overflow. Surveys show that professionals rely on tools such as ChatGPT and Copilot to seek explanations, debug errors, and clarify concepts.

Repository-Level Question Answering

Repository-level activities like program comprehension differ from their snippet-level counterparts in that they require developers to build mental models across files, modules, and heterogeneous artifacts. Prior studies show that developers rely on structural cues for system-level reasoning and adapt strategies across conceptual, debugging, and integration tasks.

Recent work on LLMs for SE moves beyond snippet-level tasks toward repository-grounded question answering (QA). SpyderCodeQA provides manually curated question-answer pairs (Q&A-pairs) for the Spyder IDE that probe code semantics, dependencies, and meta-information, but its single-project scope limits generalizability. Moreover, its approach relies on fine-tuning a model for each project, reducing practicality.

CoReQA33 3 Dataset not publicly available and CodeRepoQA present issue-derived datasets where an LLM reconstructed questions and answers from GitHub issues and discussions across multiple repositories. However, because the Q&A pairs are LLM generated rather than directly obtained from developers, these datasets do not reflect questions posed by real developers along with their accepted answers, limiting both realism and reproducibility.

Long Context vs. Retrieval Augmentation

Long-context models promise end-to-end reasoning over large repositories, but multiple studies show that performance often degrades as context length increases, and even when the relevant code is present, models often fail to locate it reliably. This is partly because longer input reduces an LLM’s ability to capture dependencies across the context. Moreover, source code relationships are not strictly linear. Cross-file dependencies and structural connections must be explicitly reasoned about.

RAG has therefore become a common strategy for grounding LLM responses. However, recent work shows that irrelevant or adversarially “hard” negatives can significantly reduce accuracy, even when relevant passages are included. This phenomenon, sometimes called the distracting-context effect, highlights the vulnerability of LLMs to noisy or misleading retrieval and motivates adaptive filtering or gating strategies.

To overcome the limitations of long-context beyond flat text-based retrieval, structure-aware pipelines have been proposed that index repositories as graphs (e.g., code property graphs, symbol graphs). Such approaches enable multi-hop queries across cross-file relations and consistently outperform flat retrieval on code tasks.

Stack Overflow Questions

We obtained the archived version of Stack Overflow questions and answers from the official data dump. The archive contains all content posted on stackoverflow.com up to April 3, 2025. We chose Stack Overflow due to its role as a primary question-answering platform for software developers, where questions are authored by practitioners encountering concrete problems and answers are vetted through community feedback and acceptance mechanisms. Prior studies have shown that Stack Overflow questions capture realistic information needs during program comprehension and maintenance, making them a reliable proxy for real-world developer questions.

In contrast to recent datasets (e.g., CoReQA, CodeRepoQA) that reconstruct or rephrase question and answer pairs (Q&A pairs) from GitHub issues using LLMs, our approach preserves the original, developer-authored questions and accepted answers. LLM-generated Q&A pairs risk introducing artifacts and implicit solution knowledge, obscuring how developers naturally formulate problems and confounding memorization with reasoning. By grounding StackRepoQA in organically produced Stack Overflow Q&A pairs with accepted answers, we prioritize realism, reproducibility, and faithful representation of developer information needs.

Experimental Setup

We first prompted the LLMs to answer Stack Overflow questions directly, without access to any external tools or augmentation. This baseline reflects the models’ inherent knowledge, acknowledging that both Stack Overflow content and public GitHub repositories are likely to be included in their training data.

Beyond this baseline, we implemented an agentic setup in which a supervisor agent interacts with one summarizer and two specialized retrieval augmented agents: a file-based RAG agent that retrieves relevant code fragments from a local copy of the repository, and a graph-based RAG agent that leverages structural dependencies stored in a Neo4j database. This framework allows the models to ground their answers in repository-specific context rather than relying solely on pretrained knowledge.

Recent work in SE highlights the benefits of agentic systems. For example, Mazur et al. show that LLMs equipped with tool access achieve accuracy comparable to direct prompting while substantially reducing token usage. Similarly, Robeyns et al. demonstrate a self-improving coding agent that iteratively refines its behavior using external tools, resulting in 17–53% performance improvements on SWE-Bench Verified benchmarks—far exceeding static LLM baselines. These findings support our design choice: agentic systems, with planning, tool integration, and feedback loops, are more effective than standalone LLMs for complex SE tasks.

Prompt Design

We structured the system prompt around five key components—Role, Context, Task, Rules, and Output—following the “prompt canvas” framework of Hewing and Leinhos and the component-based template analysis of Mao et al.. The specific prompts used for each agent are provided in the replication package.

Questions are first presented to the LLM. In the baseline evaluation, the LLM generates responses without any augmentation. In the agentic setup, the LLM routes the query through one or both retrieval agents. The retrieved context—either relevant files or graph substructures—is appended to the prompt and returned to the LLM to produce a grounded answer. We evaluate three configurations: (1) LLM only; (2) LLM + File-RAG; and (3) LLM + File-RAG + Graph-RAG.

LLM-as-judges

Given that our primary goal is to evaluate the semantic and factual similarity between the model-generated responses and reference answers, we use LLM-as-judges instead of traditional metrics like BLEU, ROUGE, or edit similarity. Traditional metrics mainly focus on surface-level overlap such as exact word matches or phrase similarity, which do not reliably capture semantic equivalence, especially when paraphrasing or varied wording occurs. Additionally, using LLMs as judges allows for a more nuanced and human-like evaluation of meaning, accounting for context and subtle variations in expression. This ensures that our evaluation aligns more closely with our goal of measuring meaningful similarity rather than mere linguistic similarity.

In the LLM-as-a-judge setup, we presented the LLM with questions from StackRepoQA along with reference and candidate answers, asking it to rate responses (on correctness, completeness, faithfulness, conciseness) between 1–10—mirroring methodologies from prior studies that employed LLMs as judges in QA and software engineering evaluations.

The evaluation prompt provided to the LLM-as-a-Judge (see replication package ) included a fixed scaffold with a clear rubric and scoring guide. Aside from the ablation study, each response was evaluated independently by two LLMs to mitigate the self preference bias observed in prior work, where models tend to assign higher scores to their own outputs compared to those of competing models.

RQ1: LLM Accuracy

Interestingly, responses to questions unrelated to the mapped project slightly outperformed those related to the project (i.e., 7.27 vs. 6.73). While this difference was not statistically significant, it suggests that the models performed consistently across both categories. However, this gap widened considerably when we prompted the LLMs to ignore their inbuilt knowledge and instead rely solely on information retrieved through external tools and agents, following established open-book and faithful question answering protocols. This pattern indicates that much of the higher performance without augmentation likely stems from the models’ prior exposure to the question–answer pairs during training, rather than from genuine reasoning over large codebases.

As part of the cutoff analysis, we partitioned questions into those asked before and after the LLM’s cutoff date (April 20, 2024 for Claude 3.5 Sonnet and June 1, 2024 for GPT-4o ). We observed a significant drop in performance after the cutoff for both models: Claude’s average score decreased from 6.59 to 5.44 (p = 0.0009), while GPT-4o’s dropped from 6.97 to 5.97 (p = 0.0024), highlighting the influence of memorized training data on their repository-level question-answering capabilities.

Overall Performance Gap

The overall accuracy achieved by both GPT-4o and Claude 3.5 remains far below what would be required for practical deployment in developer workflows. Performance degraded markedly when models were prevented from relying on memorized training data, underscoring that much of their current success stems from pretraining exposure rather than genuine reasoning over source code. Fine-tuning LLMs on individual repositories is not a sustainable solution, as projects evolve continuously. This highlights the need for more robust RAG approaches that can dynamically adapt to unseen projects and unseen changes to projects.

These findings are particularly concerning for projects where few or no public Stack Overflow Q&A pairs are available. For example in private or niche projects, models may have little or no training exposure. If LLM-generated answers are to reflect the current state of a codebase, retrieval mechanisms must be improved to capture up-to-date, contextually relevant information.

Our evaluation of the tool-only configuration, where LLMs relied exclusively on repository artifacts, further exposed the fragility of their reasoning. Without access to memorized Q&A pairs, performance collapsed. These findings should caution practitioners against the use of LLMs for repository-level program comprehension. While humans often exploit structural cues such as dependency graphs, call hierarchies, or design patterns, LLMs fail to do so effectively without tailored retrieval mechanisms. This highlights that apparent success on public benchmarks may overstate true comprehension unless memorization effects are carefully controlled.

Graph RAG as a Key Enabler

Among the augmentation strategies, graph-based RAG consistently provided stronger improvements than file-level retrieval. By modeling structural relationships such as inheritance, containment, and cross-file calls, Graph RAG supplies the type of context developers rely on in practice. This aligns with Liu et al., who reported that graph representations of structural data improved performance on code generation tasks.

Chen et al. found that even with unlimited context length, LLMs fail to capture cross-file relationships when provided the entire codebase, resulting in poor QA performance. Our evaluation further confirms this limitation and underscores the need for systematic representation and retrieval techniques, such as structural dependency graphs, for effective repository-scale reasoning. We plan to investigate how additional structural information such as call graphs and data flow could impact performance.

In line with prior work, Claude 3.5 outperformed GPT-4o in leveraging graph-based context, suggesting that model-specific differences in handling structured outputs can affect multi-agent system effectiveness. This aligns with findings from, which showed that Claude demonstrates higher proficiency in generating effective graph database queries. Future work could explore representing graph data in relational databases and compare this approach to the Neo4j graph database used in this study, in order to assess how well LLMs can generate correct Cypher queries versus SQL queries and its impact on question answering performance.

Memorization vs. Reasoning

Our cutoff-based analysis provides clear evidence that LLMs often succeed on repository-level QA tasks primarily due to memorization of Stack Overflow content. When models were prompted to ignore internal knowledge, accuracy dropped substantially, highlighting a methodological concern: evaluations that do not control for pretraining exposure risk overestimating LLM capabilities for program comprehension.

We further observed that some LLM responses were near verbatim reproductions of accepted Stack Overflow answers. We outline examples from our study with question IDs (QIDs) from our study. For example, in Debezium (QID:6887), the model reproduced the exact JSONB field access expression; in JUnit4 (QID: 8633), it closely mirrored the ground-truth explanation for covering the next method; and in Ebean (QID: 10582), it repeated the instruction to replace a primitive int with the wrapper type Integer. Similarly, responses for OpenRouteService (QID: 9255) and WireMock (QID: 37860) echoed the accepted solutions almost verbatim, including distinctive technical phrasing such as “Stateful Behaviour.” These observations suggest that the models have likely encountered these question–answer pairs during training, aligning with recent concerns about benchmark contamination in LLM evaluation. To our knowledge, this is the first empirical study to document such effects in the context of repository-level question answering.

This evidence underscores the need for future benchmarks and evaluation protocols that explicitly disentangle memorization from reasoning. Promising approaches include cutoff-based dataset splits, unseen repository evaluation, augmentation techniques that encourage reasoning over code artifacts, and metrics assessing grounding in repository context. Based on our findings, we advocate for cutoff-based evaluation and analysis as a standard for future LLM studies in software engineering.

Impact of Question Type

Analysis of scores across projects revealed that question type influences LLM performance. Though we did not perform a formal coding or analysis, we observed high-scoring responses were typically associated with API usage or conceptual clarification, while low scores were common for configuration, integration, or query-related questions. For example, questions involving Lucene API (QID: 2986) usage were answered accurately, whereas tasks requiring Solr configuration (QID: 177649) or Hibernate integration often resulted in incomplete or misleading responses. These patterns indicate that LLMs handle stable, well-documented API tasks reasonably well but struggle with repository-level reasoning that depends on context-specific details.

This aligns with prior findings on developer comprehension: conceptual or API-focused tasks demand different strategies than procedural, configuration-heavy tasks, and configuration/environment questions are particularly prone to obsolescence. Similarly, LLMs are vulnerable when contextual clutter is high or reasoning requires synthesizing multiple, evolving artifacts. The contrast between API-level and configuration-heavy tasks suggests that repository-level QA is heterogeneous. Future experiments should consider question diversity, and practitioners should combine LLMs with retrieval and filtering strategies to mitigate risks in rapidly evolving or integration-heavy environments.

Limitations

This work has several acknowledged limitations. First, StackRepoQA is limited to Java projects, chosen due to their prevalence in large-scale systems; results may differ for other programming languages or ecosystems. Second, although Stack Overflow provides a rich source of real developer questions, it may not fully capture the breadth of challenges developers face in practice, particularly in industrial settings or private repositories. Third, our evaluation focuses on a limited set of augmentation strategies—specifically file-level and graph-based RAG—leaving open the possibility that alternative approaches, such as specialized fine-tuning, could yield different results.

Threats to Validity

Our study is subject to several threats to validity. Construct validity may be affected by our reliance on accepted Stack Overflow answers as a proxy for correctness. While acceptance reflects community endorsement rather than definitive ground truth, this practice is consistent with prior empirical studies that leverage Stack Overflow data for large-scale evaluation. In addition, our use of LLM-as-a-judge evaluation may introduce bias, and while prompting models to ignore internal knowledge led to a clear performance drop, perfect compliance cannot be guaranteed.

Internal validity concerns arise from the dataset construction process. Keyword-based matching between Stack Overflow questions and GitHub repositories may still produce false positives despite manual filtering. Moreover, the choice of seven questions per project, while informed by power analysis, may not fully capture the diversity of developer questions associated with each repository.

External validity is limited by the scope of the dataset. StackRepoQA focuses on Java projects and Stack Overflow questions, which may not generalize to other programming languages, ecosystems, or industrial and private development settings. Our evaluation only incorporates two LLMs (Claude 3.5 Sonnet and GPT-4o), which may limit the generalizability of our findings across other model architectures, providers, or future generations of models.