🤖 AI Summary
This work addresses the inefficiency of large language model (LLM) agents in repository-scale code repair, where excessive context tokens are consumed by redundant file reads, broad searches, and verbose logs, often obscuring relevant evidence with irrelevant information. To mitigate this, the authors propose ContextSniper—a smart memory layer tailored for code repair—that integrates a Sniper feature selection mechanism combining hybrid retrieval signals with intent-aware context gating. This approach preserves recoverable source context while injecting only compact, high-signal evidence packages. Experimental results on SWE-bench Lite demonstrate that ContextSniper reduces token consumption by 51.5% for OpenClaw and 38.9% for Claude Code, yielding cost savings of 36.4% and 27.3%, respectively, with only a marginal 2-percentage-point drop in commit resolution rate.
📝 Abstract
Large language model agents can repair real repository issues, but they often spend large context budgets on whole-file reads, broad searches, and long terminal outputs where useful evidence is mixed with irrelevant code and logs. This paper presents ContextSniper, AntTrail's token-efficient code memory layer for repository-level program repair. As the coding specialization of AntTrail's broader agent memory engine, ContextSniper implements the Sniper feature for precision evidence selection: it retrieves candidate code and runtime evidence, ranks it with hybrid retrieval signals, filters long outputs through an intention-aware context gate, and returns compact evidence packets while preserving recoverable source context outside the prompt. We evaluate ContextSniper on SWE-bench Lite with OpenClaw and Claude Code, using 50 task runs per host-agent condition. ContextSniper reduces total token use by 51.5% and logged cost by 36.4% for OpenClaw, and reduces total token use by 38.9% and estimated cost by 27.3% for Claude Code. Submitted-resolution rates decrease slightly, from 26.0% to 24.0% for OpenClaw and from 32.0% to 30.0% for Claude Code. ContextSniper's pilot testing scripts are open-sourced at https://github.com/Calluking/ContextSniper