Editor’s introduction
The study evaluates CodeScout, a reinforcement learning recipe that trains code search agents using only a standard Unix terminal. The researchers measure localization accuracy using F1 scores across file, module, and function levels, along with precision and recall. Results show CodeScout achieves superior or competitive performance, sometimes matching closed models, without relying on specialized programming tools. Performance gains are attributed to effective reward design and agent scaffolding, with results reported only for the specified datasets and granularities.
Introduction
For repository-level coding tasks such as those in the popular SWE-Bench benchmark, a critical first step is code localization: given an issue description and a code repository, the system must identify the relevant files and finer-grained code entities (e.g., classes and functions) to modify (§2; ). This is challenging in large repositories with complex inter-dependencies, and relying on general-purpose language models to solve this localization problem as part of the agentic coding loop can result in high costs, incorrect fixes, and code bloat.
To address this issue, it is also common to incorporate some variety of specialized localization module to acquire the relevant context from large codebases in a more efficient and effective manner. Traditionally, this code search was performed through semantic code search using vector databases. In contrast, recent methods have investigated agentic code search - using agents to iteratively navigate the repository and uncover necessary evidence for solving the issue under consideration. Typically, these methods have involved significant modifications to the agent itself to incorporate static analysis of the codebase, such as LocAgent’s repository graph navigation and RepoNavigator’s “jump” tool that retrieves definitions of Python symbols. While well-grounded, these necessitate the use of static analysis tools tailored to a particular programming language, increasing operational complexity of deploying such agents on a broader variety of coding scenarios. Simultaneously, there have been various anecdotal reports from industry regarding reinforcement learning methods that increase the ability of agents to perform localization rapidly, with varying levels of detail but without a clear training recipe.
Given this background, we address the fundamental research question: given an appropriate reinforcement learning algorithm, what is an effective recipe to train a code localization agent that simply uses the terminal tool typical of more generic coding agents, yet achieves competitive or superior accuracy over agents using special-purpose tools? In this work, we provide the first public demonstration of such a recipe, which involves scalable methods for data and environment creation (§3.1), a standard agent scaffold (§3.2), as well as careful attention to reward design (§3.3) and training algorithm (§3.4). In experiments (§4, § 5), we find that the resulting model CodeScout achieves localization performance superior to or competitive with existing methods on a variety of localization datasets derived from SWE-Bench Lite, Verified, and Pro. Importantly, all models and code are released publicly, building a strong baseline for future development in the community to build upon.
Related Work
Unlike most prior methods, which either do not train LLMs using their proposed agent frameworks, such as CoSIL and OrcaLoca, or rely on supervised distillation from proprietary closed-source LLMs via rejection sampling fine-tuning, like LocAgent and RepoSearcher, CodeScout post-trains LLMs directly with reinforcement learning, thereby eliminating dependence on expensive closed-source models for data curation.
Finally, CodeScout has a significantly simpler agent scaffold both in terms of both engineering overhead and tool count. Since the bash terminal is already a core component of standard coding agents like OpenHands, SWE-Agent, and Claude Code, our approach avoids the need to implement specialized task-specific tools or agent scaffolds, unlike prior work. Moreover, when measured by the size of the agent’s action space, excluding any exit/finish tools, CodeScout uses only 1 tool, compared to 3-5 tools in prior methods. Refer to Appendix C for a more comprehensive review of prior work.
Data and Environment Curation
We curate training instances by processing GitHub issues collected by prior work, which were originally intended for training agents to fix issues. We discard issues whose PRs create or delete files, as the agent cannot predict the name of newly created files and we cannot determine ground-truth modules or functions for deleted files. We also ignore non-Python files (e.g., README.md) in the ground truth because function- and module-level information cannot be extracted from them. We also discard instances with empty issue descriptions.
We construct the RL environment by cloning the pre-PR commit of the repository to a specific location known to the agent via its prompt. Since the localization task does not require executing repository code, we do not install project dependencies or use sandboxing/containerization. Notably, since our agent scaffold only requires a terminal, environment setup overhead is significantly lower than scaffolds from prior work whose tools require code graphs, vector databases, or dependency parsers.
OpenHands-Bash: Our Agent Scaffold
We use the OpenHands Software Agent SDK to implement our scaffold as it performs strongly across software engineering benchmarks, implements core tools (e.g., terminal), supports parallel tool-calling, and offers a modular design that easily integrates with our training backend.
The agent is primarily equipped with a Terminal tool that supports standard Unix commands (e.g., rg (ripgrep), find, ls, grep, sed). We install ripgrep in the agent’s environment, which is a command-line utility for fast grep-style search using regex patterns recursively through all code files in a directory. In addition, the agent uses a LocalizationFinish tool to submit predicted files, modules, and functions. We refer to this scaffold as OpenHands-Bash.
Our initial experiments used a string-based output format from, but we found agents trained with this format to be sensitive to noisy reward signals due to brittle format validation and parsing. We address this by requiring the agent to terminate via the LocalizationFinish tool that enforces a structured output schema and simplifies parsing and validation, improving reward-signal fidelity. Appendix A includes detailed prompts and tool definitions for our agent.
Training Setup
We process the SWE-Smith dataset using the procedure from §3.1, resulting in a filtered training set of 39K instances across 128 repositories. None of these repositories overlap with those used in our evaluation benchmarks (§4.2), avoiding any risk of dataset contamination.
Evaluation Setup
We report performance on three benchmarks: SWE-Bench Verified (500 instances), SWE-Bench Lite (300 instances), and the Python subset of SWE-Bench Pro (266 instances), which is substantially more challenging than the other two. For all benchmarks, we re-purpose the datasets and extract ground-truth locations using the method in §3.1.
Evaluation Metrics
Our primary evaluation metric is the instance-wise average of F1 score between predicted locations and ground-truth locations across three granularities: file, module, and function. In addition, we report average precision and recall for each granularity to compare with baselines that predict a fixed number of locations, which often results in precision-recall disparities.
Baselines
We also evaluate other LLMs with OpenHands-Bash (§3.2). First, we benchmark the base variants of CodeScout LLMs: Qwen3-4B-Instruct-2507, and the non-thinking versions of Qwen3-1.7B and Qwen3-14B. We also include Qwen3-32B with thinking enabled to compare against a larger reasoning model. Finally, we evaluate two closed-source models, GPT-5 and Claude-Sonnet-4.5. For open-source LLMs, we use the same prompts as CodeScout, specifying a turn limit of 4 (or 6 for 4B LLMs) while allowing up to 15 turns in the backend to ensure a fair comparison, since base models may require more steps to complete the task. For closed-source models, we limit backend turns to 6 due to cost constraints. Despite specifying the turn limit in the system prompt, GPT-5 and Claude Sonnet 4.5 frequently exhaust all steps without submitting predictions, yielding a score of 0. Following RepoNavigator, we mitigate this by adding a reminder message before the last turn that prompts the LLM to submit its final answer.
CodeScout substantially outperforms base LLMs of similar and larger sizes with OpenHands-Bash
Across all evaluation benchmarks and localization granularities, CodeScout LLMs significantly outperform their corresponding base models when using the OpenHands-Bash scaffold. CodeScout-1.7B achieves absolute improvements in F1 score over its base model of 40-54% at the file level, 25-41% at the module level, and 18-28% at the function level. Similarly, CodeScout-4B yields absolute gains of 14-19%, 25-38%, and 21-31% in file, module, and function-level F1 scores, respectively. Finally, CodeScout-14B achieves substantial absolute improvements of 23-34% in file-level F1, 25-39% in module-level F1, and 20-33% in function-level F1 scores.
CodeScout outperforms larger base and post-trained LLMs using complex scaffolds
Comparisons with larger post-trained LLMs using complex scaffolds: We primarily compare CodeScout with RepoNavigator as it is our strongest post-training baseline. It is also closer to our work than RepoSearcher as it is trained without relying on closed-source LLMs and can predict a variable number of locations (§4.3).
CodeScout narrows the performance gap with closed-source LLMs
On SWE-bench Verified, CodeScout-4B and CodeScout-14B achieve superior results compared to GPT-5-Chat with RepoNavigator, outperforming it by 9% in file-level F1 and 5-9% in function-level F1. Moreover, CodeScout-4B and CodeScout-14B achieve impressive function-level localization performance surpassing the function-level F1 score of Claude-3.7-Sonnet with RepoNavigator by 5-8%. These results are significant given that CodeScout uses a bash-only agent as opposed to the specialized RepoNavigator scaffold.
Interestingly, Claude-Sonnet-4.5 achieves stronger performance with our bash-only agent over RepoNavigator, with significant improvement in function-level F1 score by 18% and a slightly better file-level F1 score (2%). Similarly GPT-5 with our agent outperforms Claude 3.7 Sonnet with the RepoNavigator scaffold, with absolute improvements in F1 of 23% for functions and 5% for files. These results suggest that designing specialized scaffolds may not always lead to better performance with frontier models and can even degrade model performance. Prior agent frameworks like OpenHands-Versa and mini SWE-Agent have reported similar findings for other task domains.
For all benchmarks, GPT-5 and Claude-Sonnet-4.5 consistently outperform CodeScout when using the OpenHands-Bash scaffold with an additional reminder (§4.3). A surprising finding is the sensitivity of these frontier LLMs to prompt engineering; without the additional reminder for prediction submission, the performance of both models drops to almost zero on all benchmarks. Interestingly, our preliminary experiments do not reveal similar problems with GPT-4o despite being an older proprietary LLM.
Does Effective Code Localization Improve Issue Resolution?
For Qwen3-4B-Instruct, improved localization quality leads to substantial gains in both performance and efficiency: augmenting the agent with locations retrieved by CodeScout-14B increases the resolution rate by 3.8%, while reducing trajectory length by 2.18 steps, and input and output tokens by 17.46% and 6.71% respectively. Similar efficiency gains are observed for Qwen3-Coder-30B-A3B-Instruct, with 2.89 fewer steps and 5.33% fewer input tokens and 2.00% fewer output tokens, while achieving comparable performance with a small improvement (+0.80%). For both models, replacing CodeScout predictions with oracle locations yields further performance gains (+6.00% for 30B and +2.40% for 4B). The 30B model additionally benefits with improved efficiency, with 1.37 fewer steps and reductions of 10.12% and 5.60% in input and output tokens. Overall, these results indicate that continued improvements in code localization will likely further enhance both the performance and efficiency of issue resolution agents.
How does the tool-use behaviour of CodeScout evolve during RL?
We observe a clear convergence in tool usage as training proceeds. While the 14B model initially invokes various utilities (e.g., grep, find, wc, and cat), after approximately 200 training steps it mostly relies only on two commands: ripgrep (rg) and sed. Similarly, while the 4B model initially uses a many utilities, it eventually converges to primarily using ripgrep, sed, cat, find and xargs. Appendix F presents example trajectories illustrating how the 4B and 14B LLMs use these utilities for code localization. These findings suggest that effective localization can be achieved using an even simpler scaffold with only a small subset of Unix utilities without requiring access to the entire Unix command-line interface which is crucial in security-sensitive deployments.
Conclusion
We present CodeScout: a fully open-source reinforcement learning recipe for training code search agents, and release the CodeScout model family that demonstrates state-of-the-art localization performance without relying on complex scaffolds dependent on programming language-specific static analysis tools as done by prior work. By leveraging a simple agent scaffold equipped with just a terminal tool, CodeScout achieves remarkable localization efficacy. Our experiments on SWE-Bench Verified, Pro, and Lite show that models trained with our recipe not only outperform significantly larger open-source models (both pre-trained and post-trained variants) across various complex scaffolds, but also close the performance gap with some proprietary closed-source LLMs. Our analysis reveals the advantages of augmenting issue resolution agents with relevant localized context both in terms of efficiency and performance. We also study the fine-grained changes in model behaviour during RL in terms of the command-line utilities leveraged for localization, revealing the feasibility of developing even simpler scaffolds with strong performance on this task. Appendix D includes additional discussion on limitations and directions for future work. We publicly release our code, data, and model weights for future work to build upon, and leverage our infrastructure to train effective LLM-based code agents.
Impact Statement
Our work studies how to train language models to perform repository-level code localization, a key capability underlying many coding agent tasks like automated issue resolution. Advances in code localization will help strengthen automated software engineering systems that rely on accurate code retrieval. Progress in coding agents has significant societal implications as they can reshape the software engineering profession, reducing the demand for certain types of routine programming tasks contributing towards workforce displacement. We advocate for the responsible development and deployment of coding agents, with appropriate safeguards and human oversight to mitigate real-world harm.
Approaches for code localization
Several prior methods have developed methods targeting code localization for downstream issue resolution in repositories. identify relevant source code files using BM25 retrieval treating the issue description as the query and the Python source code files as documents. SWE-Fixer use a two-step coarse-to-fine localization approach where they first retrieve relevant source code files using BM25 retrieval and then prompt a fine-tuned 7B model with the skeleton of the retrieved files to predict the names of relevant files for issue resolution. On the other hand, Agentless uses a complex, multi-step localization pipeline wherein it first retrieves suspicious code files from the repository using both embedding-based retrieval and by prompting an LLM with the high-level repository structure, followed by prompting an LLM to predict relevant functions and classes given the skeletons of the suspicious files.
RepoSearcher develop a light-weight scaffold with tools specialized for localization that allow searching for classes and functions in files, obtaining imports of a given file, etc. They use a two-stage approach to train open-source LLMs for their scaffold: (1) rejection sampling fine-tuning from a closed-source LLM (Claude3.7-Sonnet) to warm-up their model, (2) reinforcement learning on the fine-tuned checkpoint to further enhance performance. RepoNavigator use an even simpler scaffold comprising with just one tool - jump - which allows the agent to retrieve definitions of Python symbols in files. Although do not rely on rejection sampling fine-tuning from closed-source LLMs and directly train models using reinforcement learning, they still rely on selecting “easy” training instances by discarding all training instances that were not successfully solved by the base Qwen2.5-7B model equipped with their scaffold atleast once among 16 sampled trajectories.
Training methods for software engineering agents
Several prior approaches have trained LLM-based software engineering agents for various downstream tasks like code localization and issue resolution. Many methods rely on performing rejection sampling fine-tuning: sample trajectories (for training instances) from a stronger (often closed-source) model and train a smaller model on trajectories which successfully solve the task. Prior approaches that use this approach include LocAgent and RepoSearcher for code localization, and SWE-Gym, SWE-Smith, and R2E-Gym for issue resolution. Recently, various attempts have been made to train models directly with reinforcement learning without relying on proprietary, closed-source LLMs for rejection sampling fine-tuning. While RepoNavigator, SWE-Grep, and SID-1 train LLM agents with RL for code localization, DeepSWE and SkyRL-v0 leverage RL to train LLM agents for issue resolution.
Single-factor ablations
These findings indicate that the GSPO configuration used by CodeScout performs competitively across all granularities, supporting its use as a reasonable default. More broadly, the relatively narrow performance range across recipes indicates that, for the code localization task with Qwen3-4B/14B, the choice of reward design (§3.3) and agent scaffold (§3.2) likely matters more than the specific RL algorithm, consistent with our recipe-oriented perspective.


