CodeGrep: An RL-Trained Retrieval Agent for LLM Coding Agents

Wuya Chen, Yihao Yang, Yang Cao, Yue Lin


Abstract
Modern LLM coding agents—Claude Code, OpenHands—share a common inefficiency: they spend most of their token budget finding the file to patch, not patching it. On SWE-Bench Verified, a 30B OpenHands agent averages 23 rounds and 631K tokens per resolved issue, dominated by grep, glob, and view_file calls. No open, systematically-studied agent-style code retriever exists at scale to shorten this phase. We introduce CodeGrep, a 14B retrieval agent trained end-to-end with GRPO to issue multi-turn parallel grep/glob/read tool calls and return candidate files to a frozen downstream coding agent.

On all 500 SWE-Bench Verified instances, CodeGrep preserves the downstream resolve rate (25.8% → 27.0%, +1.2pp) while delivering a much larger efficiency gain (−15% rounds, −19% tokens on resolved instances). Across three retrievers, downstream utility follows a precision threshold: BM25 (precision 0.375) degrades the agent, Jina (0.445) is neutral, and only CodeGrep (0.677) crosses the threshold at which retrieval begins to buy efficiency. To enable this study, we mine supervision from 67K open-source agent trajectories (CATM) and build a Git-worktree environment for multi-turn agent RL. In our setting, applying the efficiency signal at the advantage layer, rather than the reward layer, holds KL drift to one-third and translates cleanly into downstream efficiency. We will release the model, training pipeline, RL environment, and evaluation harnesses.
Anthology ID:
2026.realm-1.80
Volume:
Proceedings of the Second Workshop for REsearch on Agent Language Models (REALM 2026)
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Ehsan Kamalloo, Nicolas Gontier, Nikolai Rozanov, Maryam Hashemzadeh, Akhil Arora
Venues:
REALM | WS
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
1171–1187
Language:
URL:
https://aclanthology.org/2026.realm-1.80/
DOI:
Bibkey:
Cite (ACL):
Wuya Chen, Yihao Yang, Yang Cao, and Yue Lin. 2026. CodeGrep: An RL-Trained Retrieval Agent for LLM Coding Agents. In Proceedings of the Second Workshop for REsearch on Agent Language Models (REALM 2026), pages 1171–1187, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
CodeGrep: An RL-Trained Retrieval Agent for LLM Coding Agents (Chen et al., REALM 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.realm-1.80.pdf