Developer tools · Research feature

SWE-QA: Can Language Models Answer Repository-level Code Questions?

A new benchmark evaluates large language models on real-world software repository questions requiring cross-file and multi-hop reasoning.

Adapted from research by Weihan Peng, Yuling Shi, Yuhang Wang and colleagues.

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

Authors’ overview

Understanding and reasoning about entire software repositories is an essential capability for intelligent software engineering tools. While existing benchmarks such as CoSQA and CodeQA have advanced the field, they predominantly focus on small, self-contained code snippets. These setups fail to capture the complexity of real-world repositories, where effective understanding and reasoning often require navigating multiple files, understanding software architecture, and grounding answers in long-range code dependencies. In this paper, we present SWE-QA, a repository-level code question answering (QA) benchmark designed to facilitate research on automated QA systems in realistic code environments. SWE-QA involves 576 high-quality question-answer pairs spanning diverse categories, including intention understanding, cross-file reasoning, and multi-hop dependency analysis. To construct SWE-QA, we first crawled 77,100 GitHub issues from 11 popular repositories. Based on an analysis of naturally occurring developer questions extracted from these issues, we developed a two-level taxonomy of repository-level questions and constructed a set of seed questions for each category. For each category, we manually curated and validated questions and collected their corresponding answers. As a prototype application, we further develop SWE-QA-Agent, an agentic framework in which LLM agents reason and act to find answers automatically. We evaluate six advanced LLMs on SWE-QA under various context augmentation strategies. Experimental results highlight the promise of LLMs, particularly our SWE-QA-Agent framework, in addressing repository-level QA, while also revealing open challenges and pointing to future research directions.

Introduction

Understanding and reasoning about entire software repositories is an essential capability for intelligent software engineering tools. Real-world development rarely involves reasoning over isolated functions or small code snippets; instead, developers must navigate large, interconnected codebases, trace dependencies across multiple files, and synthesize architectural knowledge to answer complex questions.

Recent advances in large language models (LLMs) have shown promise for code understanding, yet most existing evaluations target isolated code snippets, functions, or APIs. These benchmarks fail to capture the complexity of real-world repositories, including architecture, cross-file dependencies, lifecycle flows, and design rationales, which require a deeper, multi-hop understanding of code structure, semantics, and intent. While recent works like CodeRepoQA, CoreQA, and Spyder-CodeQA have begun to address repository-level understanding, they still lack comprehensive coverage of the diverse reasoning patterns and multi-hop dependencies essential for realistic software development scenarios.

To address this limitation, we propose a repository-level code question answering (QA) benchmark designed to evaluate LLMs on realistic repository-based questions. SWE-QA comprises 720 high-quality QA pairs that necessitate a deep understanding of intentions, cross-file reasoning, and multi-hop dependency analysis. To capture the diverse reasoning requirements inherent in real world, we crawled 77,100 GitHub issues from 12 repositories used by SWE-bench. Based on an analysis of naturally occurring questions raised from these issues, we developed a two-level taxonomy of repository-level questions and constructed a set of seed questions for each category. Guided by our taxonomy and seed templates, we instantiated candidate questions from 15 repositories (12 from SWE-Bench and 3 from SWE-Bench-Live ) using LLMs, then manually screened and refined them to obtain 48 high-quality QA pairs per repository. Each question was answered based on retrieved context by a strong LLM, and preliminary answers were reviewed for correctness, completeness, and clarity. This process produces high-quality reference answers grounded in code context, forming a reliable and scalable benchmark with diverse reasoning requirements.

Seed Collection and Taxonomy Construction

To ensure SWE-QA reflects the complexities of real-world software engineering, we first conducted an empirical study to understand the types of questions developers pose when working with large codebases. We systematically collected and analyzed a large corpus of questions from GitHub issues to build a comprehensive taxonomy of repository-level questions. This taxonomy serves as the foundation for our benchmark construction.

Our data collection process began by crawling 77,100 GitHub issues from the 12 popular repositories used in SWE-bench (details of collected issues are available in Appendix A.1). To focus on substantive discussions, we filtered for issues with a body length of at least 1,000 characters, resulting in a dataset of 41,955 issues. Given that issues often contain extensive descriptive text, we employed a large language model to parse each issue and extract explicit questions related to code understanding (see Prompt E in Appendix E for details). This process yielded 127,415 distinct questions, with an average of 3.04 questions per issue.

Answer Collection

Step 1: Context Retrieval. For each question, we first build a comprehensive index of the target repository’s code elements, including functions, classes, and their inter-dependencies. Using this index, we retrieve relevant code snippets, documentation, and architectural metadata through a combination of semantic similarity matching and structural dependency analysis. This ensures a rich, relevant context for answer generation.

Step 2: Initial Answer Generation. With the retrieved context, we utilize a powerful LLM, assisted by 4 human experts with at least three years of experience in software development using tools like Cursor, to generate a preliminary answer. This process is guided by a prompt that emphasizes factual accuracy, completeness, and strict adherence to the provided context. The prompt explicitly directs the model to cite code locations and avoid introducing information not present in the retrieved materials, thus minimizing hallucination. The resulting question-answer pairs serve as the input for the subsequent data validation stage.

Data Validation

Step 1: Expert Answer Revision. Each generated answer is manually reviewed by our expert team. With the assistance of LLM-powered tools like Cursor, reviewers meticulously verify the factual accuracy of every claim, assess the completeness of the explanation, and refine the language for clarity and precision. Each question is answered independently by two experts, and their answers are cross-validated; if there is significant disagreement, a third expert also participates in answer generation and the three discuss to reach a final consensus. This human-in-the-loop approach allows for nuanced corrections that automated systems might miss, ensuring each answer is not only correct and complete but also easy to understand.

Step 2: Quality Filtering. After revision, the QA pairs are subjected to a final filtering step. Pairs are discarded if they fail to meet our quality standards. The criteria for filtering include, but are not limited to: questions that are ambiguous or poorly formulated, answers that remain factually incorrect or incomplete after revision, or answers that cannot be sufficiently grounded in the repository’s code and documentation. We also enforce per-repository balance across Level-1 categories (What, Why, Where, How), yielding exactly 48 finalized pairs per repository. This stringent filtering ensures that only the most clear, correct, and valuable QA pairs are included in the final SWE-QA benchmark.

Statistics of SWE-QA

The benchmark comprises 720 questions meticulously curated from 15 Python repositories. In total, these repositories encompass 13,300 files, 22,522 classes, 142,404 functions, and over 3.4 million lines of code, presenting a substantial and realistic challenge for code understanding models. The average question length is 28.62 words, and the average answer length is 266.64 words. To further characterize the complexity of SWE-QA, we conduct a quantitative analysis of the reasoning chain and structural requirements of its questions. On average, answering each question involves 8.71 functions across 3.19 files, with a reasoning chain depth of 4.72 and a dependency chain depth of 2.96. Moreover, 90.9% of the questions exhibit a reasoning chain depth greater than one, and 77.6% require cross-file knowledge to be answered correctly, indicating that SWE-QA systematically emphasizes multi-hop reasoning and non-trivial code dependencies. To ensure a balanced representation of question types, we selected an equal number of What, Why, Where, and How questions, with each repository contributing exactly 48 samples. Detailed statistics for each repository can be found in Appendix A.4.

Repository-Level Granularity and Complexity. Unlike benchmarks targeting isolated code elements (e.g., functions or classes), SWE-QA evaluates repositories, reflecting real-world tasks that require cross-file context, architectural understanding, and dependency tracking. This design challenges models to answer questions in complex, interconnected codebases, with substantially higher cognitive and structural demands than existing code QA datasets.

Pipeline-Level Extensibility. SWE-QA serves as both a benchmark and a modular pipeline for generating new repository-level QA instances applicable to any open-source project. Leveraging static code analysis, LLM prompting, and human filtering, new benchmarks can be continuously and semi-automatically created, ensuring scalability and adaptability to evolving codebases.

Evaluation

To showcase the usefulness of SWE-QA, we assess the performance of language models on repository-level code question answering using the proposed benchmark. Our objective is to uncover novel insights that have not been previously explored through comprehensive and in-depth comparisons of existing language models.

Metrics

We adopt an LLM-based evaluation (LLM-as-Judge) to assess repository-level code question answering performance (see Prompt E). Prior studies have demonstrated the reliability of LLM-as-Judge across both natural language generation and software engineering tasks. Given a model’s output and the gold answer, an LLM—Claude Sonnet 4.5 in our experiments—evaluates answer quality along five dimensions: correctness, completeness, relevance, clarity, and Coherence. Each dimension is scored on a 20-point scale, yielding a total score of 100 (see Appendix B.2 for details). To mitigate potential self-evaluation bias, we enforce strict judge–candidate separation, anonymize systems, randomize answer order, and complement automated evaluation with a human study (Appendix C.1).

Impact of Context Augmentation Methods

We first examine the effect of context augmentation. Direct prompting without repository context consistently yields the lowest performance across all models (e.g., Kimi K2 scores 51.47/100), highlighting the necessity of grounded code context. Both Sliding Window RAG and Function Chunking RAG substantially improve results by retrieving relevant code snippets (e.g., Kimi K2 improves to 62.44 with Sliding Window RAG). Agent-based frameworks further boost performance by enabling iterative reasoning and tool use, leading to the best results among open methods (e.g., Kimi K2 reaches 67.72 with SWE-agent). Overall, richer and more structured context access translates into steadily improved answer quality.

Impact of Language Model Choice

Model choice also plays a critical role. GPT-5.1 achieves the best overall performance, reaching 70.79 when combined with OpenHands. Notably, strong open-source models perform competitively: GLM-4.6 with OpenHands attains 70.15, closely matching GPT-5.1. In contrast, smaller models such as Qwen3-Coder-30B-A3B-Instruct benefit less from agent frameworks, with agent-based methods performing on par with or worse than RAG. This suggests that effective agent planning, tool invocation, and long-term memory remain challenging for smaller-capacity models.

Performance of Commercial Programming Tools

We further evaluate two commercial programming tools, Tongyi Lingma and Cursor. Both exhibit strong performance, with Cursor achieving 70.66—second only to GPT-5.1 with OpenHands—and Tongyi Lingma scoring 69.07. As highly integrated systems combining proprietary LLMs with advanced retrieval and orchestration, their results provide a strong reference point and underscore the effectiveness of end-to-end, tool-augmented solutions for complex repository-level question answering.

Taxonomy-Aware Analysis

The results reveal a discrepancy between high-level, conceptual questions and low-level, implementation-focused queries. Models consistently achieve the highest scores on Why questions (average 69.77), particularly “Design rationale” (71.48), and perform well on How questions related to “API / Framework Support” (68.75). This suggests models excel when the required information is explicitly expressed in natural language (e.g., docstrings, comments, architectural notes).

Performance is lower on questions that require deep procedural or locational understanding. What questions (e.g., explore architectures or trace dependencies) yield the lowest average score (65.81), with “Architecture exploration” at 61.84. Where questions (66.76), which demand precise location, also remain challenging. These categories often require reconstructing dispersed logic across files and implicit control paths beyond inline documentation, stressing code tracing and dependency reasoning.

Cross-Repository Generalization

On average, most repositories present a similar level of difficulty, with scores clustering around the 70-point mark. For instance, “django” (67.39), “astropy” (68.29) and “scikit-learn” (71.34) show comparable results. However, we observe notable outliers. The “flask” repository appears to be easier on average (75.42). Conversely, “pylint ” (62.01) and “conan” (64.51) are more challenging. This variance aligns with factors such as codebase size, architectural complexity, plugin or hook systems, API surface clarity, and unconventional patterns that increase reasoning depth.

Furthermore, the 12 repositories selected from SWE-Bench achieve an average score of 68.59, whereas the 3 repositories drawn from SWE-Bench-Live average 64.98, representing a decrease of 3.61 points. This gap may be related to the reduced data leakage in SWE-Bench-Live, which makes the evaluation more challenging.

Several benchmarks have been developed to evaluate code question answering (QA) systems, from snippet-level to emerging repository-level assessments. CodeQueries evaluates single- and multi-hop reasoning over Python code with annotated answer spans. CoSQA uses real user queries from Bing labeled by answer correctness. CodeQA generates Q&A pairs for Python and Java methods via templates. CS1QA provides 9,237 Q&A pairs from introductory Python courses, including tasks like question type classification and code line selection. Recent repository-level benchmarks include CodeRepoQA with 585,687 entries across five languages, CoreQA from GitHub issues across 176 repositories, Spyder-CodeQA with 325 Python Q&A pairs, InfiBench for freeform real-world questions, and ProCQA from StackOverflow. These benchmarks highlight the challenge of handling long-range dependencies and multi-file contexts. However, most evaluations focus on isolated snippets or functions and do not capture repository-level complexity. Meanwhile, repository-level techniques have advanced rapidly across code generation, translation, issue resolution, and optimization, with retrieval-augmented and agent-based approaches showing particular promise, yet standardized evaluation for comprehensive repository understanding remains lacking. To address this gap, we propose a repository-level QA benchmark to evaluate LLMs on realistic, multi-file code understanding tasks.

Conclusion

In this paper, we present SWE-QA, a new benchmark for evaluating LLMs on realistic repository-level code questions. SWE-QA consists of 720 high-quality question–answer pairs spanning 15 Python repositories from SWE-Bench and SWE-Bench-Live, and is designed to capture practical reasoning challenges such as multi-hop dependencies and cross-file context. In future work, we intend to extend SWE-QA to additional programming languages and dynamically evolving repositories to enable broader and more robust evaluation of AI-assisted code intelligence tools.

Limitations

Despite the strengths demonstrated by SWE-QA, several limitations remain. First, SWE-QA focuses on Python repositories, which may limit the generalizability of our findings to other programming languages, despite the language-agnostic design of our methods. Second, our evaluation relies on a combination of LLM-as-Judge and limited-scale human evaluation; although the latter is used to validate the former, both may introduce biases and may not fully capture all nuances of answer quality. Third, the benchmark is constructed from static code snapshots and does not reflect the dynamics of evolving repositories. Finally, while we select 15 diverse repositories, they may not cover the full spectrum of software projects, particularly smaller or highly domain-specific codebases.

LLM-as-Judge Evaluation Protocol

Given a model output and the corresponding gold answer, we use Claude Sonnet 4.5 as an automatic judge to assess answer quality along five dimensions: (1) correctness, factual accuracy; (2) completeness, coverage of all aspects of the question; (3) relevance, pertinence to the given question; (4) clarity, structural organization and readability; and (5) coherence, logical coherence of the reasoning process.

To improve reliability, each instance is evaluated five times per dimension, with majority voting used to determine dimension-level scores that are then aggregated into a single instance-level score. To mitigate bias, candidate systems are anonymized and answer orders are randomly shuffled across trials. The judge model is fixed, distinct from all candidate models, and never evaluates its own outputs. Overall, this protocol provides a robust assessment of both semantic accuracy and logical coherence. The complete LLM-as-Judge prompt is provided in Prompt E.

Human Evaluation

While the LLM-as-Judge approach offers a scalable evaluation method, it is susceptible to inherent biases. To complement our automated metrics and obtain a more reliable assessment of answer quality, we conduct a human evaluation. Specifically, we recruited three professional software engineers, each with over three years of development experience, who are not co-authors of this paper. For each question, we presented the participants with the reference answer and the answers generated by fives approaches based on the GPT-5.1 model. To ensure fairness, answers were randomized and participants were blind to the generating approach. Each participant was asked to rate the answers on a 20-point scale across the same five dimensions used in our automated evaluation (Section 3.1). This experimental design is consistent with established practices in related research.

Cost Analysis

However, this massive cost discrepancy highlights a critical cost-performance trade-off in repository-level reasoning. Taking GLM-4.6 as an example, employing OpenHands instead of Function Chunking RAG improves Correctness from 9.48 to 11.91 and Completeness from 7.52 to 12.70. This substantial improvement—particularly the nearly 70% increase in Completeness—indicates that while RAG methods are cost-efficient, they often fail to comprehensively capture all useful context for complex, multi-hop repository queries. Therefore, for practitioners, choosing between RAG and agent frameworks requires carefully balancing budget constraints against the necessity for exhaustive code comprehension.