ContextSniper: AntTrail's Token-Efficient Code Memory for Repository-Level Program Repair
Summary
ContextSniper is an open-source, token-efficient code memory layer designed to optimize large language model agents for repository-level program repair. It integrates between a host coding agent and a repository, retrieving and ranking candidate code and runtime evidence using hybrid signals, then filtering long outputs via an intention-aware context gate. This process returns compact evidence packets to the agent while preserving recoverable source context. Evaluated on SWE-bench Lite with 50 task runs per condition, ContextSniper reduced total token use by 51.5% and logged cost by 36.4% for OpenClaw. For Claude Code, it achieved a 38.9% reduction in total token use and a 27.3% estimated cost reduction. Submitted-resolution rates saw slight decreases, from 26.0% to 24.0% for OpenClaw and 32.0% to 30.0% for Claude Code.
Key takeaway
For MLOps Engineers managing LLM-based coding agents for repository repair, integrating ContextSniper can significantly reduce operational costs and latency. You should consider deploying this memory layer to optimize token usage, as it filters noisy context while preserving critical repair evidence. This approach ensures your agents receive compact, relevant information, making their debugging and patching workflows more predictable and efficient, especially for evolving codebases.
Key insights
ContextSniper optimizes LLM agent context by aggressively filtering irrelevant code and logs, preserving only repair-relevant evidence.
Principles
- Context as evidence, not ballast.
- Retrieve broadly, expose narrowly.
- Memory freshness is critical for source grounding.
Method
ContextSniper uses an AGFS-backed L0-L2 memory hierarchy, adaptive top-k hybrid retrieval, and an intention-aware context gate, synchronized with repository edits.
In practice
- Integrate ContextSniper as an insertion layer for existing coding agents.
- Use hybrid retrieval (semantic, BM25, ctags, graph) for code search.
- Store original tool outputs in action memory for recovery.
Topics
- Repository-Level Program Repair
- LLM Coding Agents
- Token Efficiency
- Code Memory
- Retrieval-Augmented Generation
- SWE-bench Lite
Code references
- Calluking/ContextSniper
- liyucheng09/Selective_Context
- Kayariyan28/ctxbudgeter
- Madhan230205/token-reducer
- rtk-ai/rtk
Best for: AI Engineer, Research Scientist, AI Scientist, Machine Learning Engineer, MLOps Engineer
Related on AIssential
See Counsel's argued verdicts on the open AI decisions leaders are weighing →
Editorial summary, takeaway, and curation by AIssential. Original article published by cs.AI updates on arXiv.org.