Overview
CodeGrep is introduced as a 14B retrieval agent specifically designed to enhance the efficiency of large language model (LLM) coding agents. The system is trained end-to-end using GRPO (Generalized Policy Optimization) to execute multi-turn parallel grep, glob, and read tool calls. Its primary function is to identify and return candidate files to a frozen downstream coding agent. The development included mining supervision from 67K open-source agent trajectories using CATM and constructing a Git-worktree environment tailored for multi-turn agent reinforcement learning (RL).
Research Context
Modern LLM coding agents, such as Claude Code and OpenHands, exhibit an inefficiency where a significant portion of their token budget is allocated to identifying files for modification rather than to the modification process itself. For example, a 30B OpenHands agent on SWE-Bench Verified averages 23 rounds and 631K tokens per resolved issue. A substantial number of these calls are dedicated to repository exploration using commands like grep, glob, and view_file. This observation highlights a bottleneck in the current operational paradigm of these agents, indicating a need for more efficient file retrieval mechanisms.
Approach
The research developed CodeGrep as a retrieval agent trained with an RL methodology. The training involved GRPO, and the agent's objective was to perform multi-turn parallel tool calls for grep, glob, and read. The agent's output consists of a set of candidate files, which are then passed to a downstream coding agent. A key aspect of the methodology involved applying the efficiency signal at the advantage layer during RL training, rather than the reward layer. This approach was observed to reduce KL drift and effectively translate into downstream efficiency improvements. The researchers utilized a dataset derived from 67K open-source agent trajectories for supervision, processed via CATM. A dedicated Git-worktree environment was built to facilitate multi-turn agent RL.
Findings
- On the full suite of 500 SWE-Bench Verified instances, CodeGrep maintained the resolve rate of the coding agent. Specifically, CodeGrep yielded a 27.0% resolve rate compared to the no-retrieval baseline's 25.8%.
- CodeGrep substantially improved efficiency on resolved instances, resulting in 15% fewer rounds and 19% fewer tokens.
- Analysis of different retrieval mechanisms revealed a precision threshold for downstream utility. BM25, with a precision of 0.375, degraded the agent's performance. Jina, with a precision of 0.445, showed a neutral impact. CodeGrep achieved a precision of 0.677, which crossed the threshold where retrieval began to reduce the overall rollout cost.
- Applying the efficiency signal at the advantage layer during RL training contributed to reduced KL drift and translated into observed downstream efficiency gains.
Potential Applications
The research indicates that CodeGrep's methodology, particularly its ability to efficiently identify relevant files, could be applied to improve the operational efficiency of LLM coding agents. This could potentially lead to reduced computational resource consumption (tokens) and faster resolution times (fewer rounds) for coding tasks handled by such agents.
Key Limitations Mentioned by Researchers
The source document does not explicitly state limitations of the research or CodeGrep identified by the researchers.