Developer tools · Research feature

SWE-QA-Pro: A Representative Benchmark and Scalable Training Recipe for Repository-Level Code Understanding

A new benchmark evaluates how well AI models navigate and understand real codebases, focusing on tasks requiring genuine exploration rather than memorized answers.

Adapted from research by Songcheng Cai, Zhiheng Lyu, Yuansheng Ni and colleagues.

arXiv preprint revision · 2026-03-17 · Attribution & reuse
In this article
(b) Semantic distribution of QA Datasets: Comparison among our Training/Test splits and SWE-QA.
(b) Semantic distribution of QA Datasets: Comparison among our Training/Test splits and SWE-QA.

Editor’s introduction

The study introduces SWE-QA-Pro, a benchmark designed to assess agentic code understanding by using diverse, long-tail software repositories with executable environments. It filters out questions solvable by direct answers, ensuring tasks require actual codebase navigation. This design reveals a significant performance gap between direct answering and agentic models, confirming that true code understanding demands active exploration. The research also presents a scalable training method combining supervised fine-tuning and reinforcement learning from AI feedback, enabling smaller models to learn effective tool use and reasoning. A Qwen3-8B model trained with this method outperforms GPT-4o on the benchmark, showing the effectiveness of the agentic training approach. However, the benchmark is limited to 260 questions across 26 repositories due to high verification costs, and it is restricted to the Python ecosystem because of sandbox execution requirements. These constraints may limit its ability to represent the full diversity of software development practices.

Introduction

Repository-level code understanding is central to LLM-assisted software engineering. Real tasks require navigating many files, tracking control and data flow across modules, and verifying that implementations match intended designs. Snippet-centric QA benchmarks do not capture these behaviors, and knowledge-only prompting can hide weaknesses in navigation and grounding. Recent repository QA benchmarks move toward large-context, tool-using evaluation, but still focus on few projects and include many questions solvable without interacting with the codebase..

We focus on two concrete gaps. First, limited diversity: existing benchmarks concentrate on a few popular repositories. This leaves large parts of the natural task distribution uncovered and under-represents certain semantic categories of tasks (e.g., configuration, data plumbing, infrastructure glue shown in Appendix A). Second, uncertain need for tools: many benchmark questions can be answered from prior knowledge or public documentation that is already covered during pretraining, so current setups do not clearly separate cases that actually requires tool-using from the cases where a single-pass, knowledge-only model with enough context and reasoning would already succeed. As a result, it is difficult to tell whether a model truly understands and operates within a particular repository, or simply recall generic knowledge.

To reduce knowledge-only questions and make tool usage meaningful, we add a simple filtering step. For each drafted item, we compare a direct-answer baseline (no tools, single turn) with a tool-using run. If the direct-answer baseline already achieves a high score, we discard the item. This preserves questions that require locating and citing concrete code rather than recalling documentation.

Data Sourcing and Taxonomy

To organize this data, we applied a hierarchical K-Means clustering algorithm, initializing with 10 clusters in the first layer and expanding to 50 in the second. We then utilized GPT-4.1 to extract semantic labels for each resulting cluster. These labels were refined through a human-verified taxonomy to eliminate semantic redundancy and enforce clear semantic boundaries between closely related categories, thereby reducing ambiguity and yielding 48 distinct task subclasses in Appendix E. This unsupervised taxonomy serves as the foundational structure for our benchmark, ensuring it covers a wide spectrum of software engineering challenges rather than a manually cherry-picked subset.

Data Synthesis and Sampling

For each synthesis task, we stochastically sampled 20 existing issues from the corresponding cluster and repository to serve as reference context. The agent was then tasked with automatically exploring the codebase to generate a new, self-contained problem-solution pair aligned with the specific cluster’s semantics.

Data Filtering and Difficulty Calibration

To ensure SWE-QA-Pro focuses on non-trivial, agent-essential reasoning, we apply a multi-stage filtering and calibration pipeline. We first remove multi-query prompts and perform semantic deduplication using Qwen3-8B embeddings to ensure task independence. A key challenge in evaluating repository-level understanding is that state-of-the-art proprietary LLMs possess extensive pretraining knowledge, enabling them to answer many software engineering questions without interacting with the codebase, reading source files, or exploring repository structure. Such questions are often associated with widely known repositories (e.g., the canonical projects in SWE-Bench ), or can be resolved by inspecting only one or a small number of files, without requiring multi-hop reasoning over the repository. Empirically, this issue is reflected in existing repo-level QA benchmarks, where the performance gap between models answering with full repository exploration and those responding without any code context is often marginal. As a result, these benchmarks may fail to accurately measure an LLM’s ability to explore codebases and perform grounded, repository-level reasoning.

Data Validation and Statistics

To ensure the quality and reliability of QA pairs and metadata, we adopt a multi-stage annotation and validation process to mitigate hallucinations and semantic ambiguity. First, Claude Code explores each repository in a sandbox environment to produce repository-grounded reference answers, while assigned semantic clusters and QA types are cross-checked against the taxonomy and reused for difficulty calibration.

Second, human annotators independently explore the codebase to produce answers, revise ambiguous or underspecified questions, and verify QA types and semantic clusters. Their answers are compared against the Claude Code references to identify missing details or errors, and only answers satisfying correctness, completeness, relevance, clarity, and reasoning quality are retained. A final expert review pass adjudicates remaining inconsistencies and further refines the answers.

The resulting SWE-QA-Pro benchmark contains 260 questions from 26 long-tail repositories, with 4–9 questions per semantic cluster and an approximately balanced distribution of QA types. Full statistics are reported in Appendix F, with case studies in Appendix H.1.

SWE-QA-Pro Agent

We introduce SWE-QA-Pro Agent, a lightweight workflow designed for repository-level code understanding in small open-source models. Unlike RAG-based approaches that require pre-built indices, our agent uses a ReAct-style loop to explore codebases directly. By combining directory traversal, keyword search, and scoped file inspection, the agent gathers evidence incrementally to reason across files under limited context budgets.

Agent Workflow

We propose SWE-QA-Pro Agent, a ReAct-based workflow for repository-level code understanding. Prior agents such as SWE-QA-Agent primarily rely on RAG-style retrieval with limited command-line support, requiring the construction of a retrieval index while still offering insufficient capacity for genuine repository exploration. This limitation is particularly evident for open-source models, where such agents often underperform strong traditional RAG baselines with offline indexing and manually designed retrieval pipelines.

In contrast, SWE-QA-Pro Agent abandons RAG-based retrieval entirely and does not require a pre-built index. Instead, it performs direct repository exploration using explicit, length-controlled Search based on keyword matching to locate relevant files, View for scoped inspection of file contents or directory structure, and constrained read-only CommandLine actions for lightweight structural and pattern-based analysis (e.g., directory traversal, symbol matching, and line-level extraction), enabling more flexible and effective context acquisition for reasoning under limited context budgets.

The agent operates in a ReAct-style loop, where it iteratively reasons over the current context, freely selects an action, and incorporates the resulting observation until sufficient evidence is collected, at which point it terminates with Finish. Detailed algorithms are provided in the Appendix B.

Agentic Training Recipe

To our knowledge, existing efforts to enhance open-source LLMs for SWE-QA focus on SFT of agentic behaviors, without leveraging reinforcement learning to optimize repository-level exploration and reasoning. Inspired by recent advances in RL for LLMs, we propose a scalable training framework that explicitly trains agentic interaction with code repositories, leading to improved exploration and understanding.

Training Data Construction. Starting from the benchmark question construction pipeline, we deduplicate and obtain 1,464 raw questions, which are randomly split into 1,000 questions for SFT and 464 questions for RL. For the SFT stage, we use Claude Sonnet 4.5 to generate 1,000 high-quality multi-turn conversation trajectories conditioned on each question and our predefined agent action space (Search, View, and read-only CommandLine tools), resulting in tool-augmented supervision data. For the RL stage, we assign each question a high-quality reference answer generated by Claude Code, which serves as the ground truth for reward computation.

Experimental Setup

Model selection We evaluate 11 LLMs, including proprietary models, GPT-4o, GPT-4.1, Claude Sonnet 4.5, Gemini 2.5 Pro, DeepSeek-V3.2, open-source models, Qwen3-8B/32B, Devstral-Small-2-24B-Instruct, LLaMA-3.3-70B-Instruct, and two variants of SWE-QA-Pro 8B trained with SFT and SFT+RL. All models are evaluated under both direct answering and agent-based reasoning using the SWE-QA-Pro Agent workflow.

Inference and Training Setup All inference uses temperature 0, a maximum of 25 turns, and a 32k context window on NVIDIA A100 80GB GPUs. SFT and RL are implemented using SWIFT and Verl-Tool, respectively. Hyperparameters are provided in Appendix C.

Evaluation Metrics We follow the LLM-as-Judge protocol of SWE-QA, including strict judge–candidate separation, anonymization, and randomized answer order. Compared to SWE-QA, we require explicit file-path and line-number references and use a stricter judge prompt to enable finer-grained score differentiation. Each answer is scored independently three times, and scores are averaged to reduce variance. Full prompts are provided in Appendix D.

Main Results

Overall Performance. Among all evaluated models, Claude Sonnet 4.5 achieves the highest overall score, reflecting strong repository-level code understanding and effective tool use. Despite its smaller scale and limited training data, SWE-QA-Pro 8B outperforms many open-source baselines as well as GPT-4o with case study in Appendix H.2, and performs competitively with larger agentic models such as Devstral Small 2 24B Instruct. These results highlight that explicitly training agentic capabilities for repository-level QA can be more impactful than scaling model size alone.

Regarding repositories and semantic clusters in Appendix G.2 and G.3, configuration and workflow management areas involving dependency injection, CLI argument handling, and packaging prove consistently difficult. These clusters characterize configuration-driven repositories like jsonargparse, checkov, and yt-dlp, where answering requires reasoning over implicit control flow, cross-file propagation, and runtime behavior not localized to single files. In contrast, clusters with explicitly encoded, localized logic, such as Unicode/data parsing, protocol/API compatibility, filesystem config, and visualization, are easier. Consequently, repositories concentrating on these areas (docker-py, pint, mkdocs, seaborn) achieve higher, stable performance, benefiting from structurally explicit and locally grounded code.

Code-centric and Repository-level QA Benchmarks. Existing code and repository QA benchmarks focus on localized or context-limited settings, where questions can be answered from snippets, APIs, or documentation. Representative datasets such as CodeQueries, CS1QA, CoSQA, CoSQA+, and CodeSearchNet emphasize element-level reasoning or retrieval over individual functions, deliberately avoiding cross-file dependencies and repository structure. InfiBench extends evaluation to free-form coding-related questions across languages, but remains knowledge- and snippet-centric rather than repository-grounded.

More recent efforts move toward repository-scale evaluation. LongCodeBench relies on long context windows to ingest large codebases, while RepoChat uses offline indexing for structured retrieval. SWE-QA formulates repository understanding as a QA task, but does not explicitly separate cases solvable by standard retrieval. In contrast, SWE-QA-Pro targets long-tail, executable repositories and filters out retrieval-solvable queries, isolating scenarios that require interactive code exploration.

Repository-level Agents. Agents in software engineering largely target generative tasks, including issue resolution, program repair, and code generation. In these domains, exploration is implicitly shaped by generation objectives rather than comprehension. Conversely, repository-level QA demands strict code navigation and understanding. Prior approaches, such as SWE-QA-Agent, rely on inference-time heuristics for tool use, often underperform retrieval-augmented generation (RAG) baselines due to unoptimized navigation. We address this limitation by explicitly training repository exploration policies, bridging the gap between passive retrieval and active agentic navigation.

Conclusion

In this work, we address the challenge of evaluating and training Large Language Models for repository-level code understanding, where reliance on memorized knowledge often masks deficits in genuine exploration capabilities. By introducing SWE-QA-Pro, we establish a rigorous testbed that enforces semantic diversity through long-tail repositories and systematically filters out questions solvable by direct answering. The substantial performance gap observed between direct and agentic baselines on this benchmark confirms that our design successfully isolates tasks requiring authentic codebase navigation and evidence grounding.

Limitations

The objective of SWE-QA-Pro is to provide a challenging benchmark and practical training recipe, yet we identify three limitations. First, despite employing semantic embedding clustering to maximize topical coverage, the benchmark is constrained to 260 questions from 26 repositories due to the high cost of expert human verification; this scale may not fully capture the extreme long-tail diversity of the software ecosystem, and the embedding models used for clustering could inadvertently introduce latent biases into the taxonomy. Second, the benchmark is currently restricted to the Python ecosystem due to the strict requirement for executable sandboxes to verify agent actions, though our data synthesis and agentic training pipeline is inherently language-agnostic and can be readily extended to other languages with compatible runtime environments. Third, our RLAIF training objectives share a similar distribution with evaluation metrics as both rely on LLM-as-a-Judge frameworks, creating a potential risk of reward hacking where models optimize for judge preferences rather than objective correctness. While preliminary case studies did not reveal significant gaming behaviors, this proximity suggests that future research should prioritize investigating more robust training methodologies—such as process supervision or diverse reward modeling—to mitigate such alignment risks.

Potential Risks

This work focuses on training and evaluating large language models for repository-level code understanding and question answering, using real-world open-source project code. While all questions are grounded in executable repositories and paired with validated reference answers, models may still produce incomplete or misleading responses when codebase exploration or tool usage fails, particularly in cases of implicit reasoning errors or silent failures. This work involves only publicly available open-source repositories and does not include any personal, sensitive, or user-generated content.

Artifact Use Consistent With Intended Use

All external datasets and software components were used in accordance with their original license agreements and intended purposes. Derived artifacts are intended solely for research and educational use, and are not authorized for commercial deployment or redistribution.

Data Contains Personally Identifying Info or Offensive Content

All data was either synthetically generated or obtained from public sources. Automated filters and manual review were applied to ensure that no samples contain personally identifying information or offensive content. All instructions and tables are free of references to real individuals, groups, or sensitive contexts.

This work exclusively uses data derived from publicly available open-source software repositories and their associated issue trackers. All data was collected in accordance with the repositories’ publicly stated licenses and terms of use, which permit research, analysis, and redistribution. As no private, restricted, or user-submitted personal data is included, explicit individual consent was not required. The data collection and curation process does not involve interaction with repository contributors, nor does it introduce new uses beyond the original public and open-source context.