Repair agents burn most of their context re-reading whole files, running broad searches, and scrolling verbose terminal logs — noise that inflates cost and dilutes the few lines that actually matter. This system indexes the codebase and the agent's own action history at three levels of detail, ranks evidence with a mix of retrieval signals, and filters tool output into a compact packet before it reaches the prompt — the full source stays one lookup away. Tested on two production coding agents against real GitHub bug-fix tasks, that cut tokens by up to 51.5% and cost by up to 36.4%, with the repair rate essentially unchanged.
An agent repairing a real repository issue doesn't get handed the ten relevant lines — it has to find them. So it reads whole files, runs broad searches, and scrolls long terminal output, and "as interactions accumulate, the active context grows with both useful evidence and stale exploration residue." Every extra round trip costs tokens, and every extra page of noise dilutes the lines that actually matter for the fix.
ContextSniper indexes both the codebase and the agent's own action history the same way, at three levels of abstraction — a compact view for everyday recall, a structured index for locating things, and the full content kept in reserve. Step through what each level actually holds.
A hybrid ranker decides what surfaces from that index: it fuses semantic embeddings, BM25 lexical scoring, ctags-style symbol metadata, and graph relations (imports, calls, containment) into one ranking via weighted reciprocal rank fusion. Toggle signals off and watch it fall back to plain text search once the fused ranking has nothing left to work with.
Before anything reaches the prompt, an intention-aware context gate strips what it can from long reads and command output. Pick a source to see what it keeps versus what it removes.
The comparison is matched: same 50 tasks, same host agent, only the context layer differs. Pick a host agent and watch tokens, cost, tool calls, and the resolved-task rate move together.
A separate, smaller check ran the same repair task through six existing memory- and retrieval-augmented-generation integrations on five Django-repository tasks. ContextSniper still used the fewest tokens of the group. The paper flags this as exploratory given the small sample.
ContextSniper used fewer tokens on 45 of the 50 matched OpenClaw tasks. On the other 5, it used more — either fixed retrieval overhead outweighing a very short task, or the compact packet simply missing the file that mattered. Toggle between the two failure shapes.
Retrieval quality also varies by repository — some codebases index cleanly, others don't. Recall for the actual target file ranged widely across repos:
Coding agents aren't the only ones that dump raw material into the prompt — a support-ticket agent pasting entire threads, a codebase-QA bot pasting whole files, an ops agent pasting full log dumps, all pay the same tax. Flip the same step between raw and indexed access. Illustrative walkthrough — the panel is simulated; the paper's measured effects are the direction, not these exact numbers.
The paper's own validation is noisy: SWE-bench Lite has known validation-error imbalance, so the near-identical resolution rate is suggestive, not a strong repair-quality claim — the authors recommend a more standardized benchmark for that. Retrieval quality still depends on embeddings, chunking, and symbol extraction, and evidence that's weakly signaled or spread across unusual files can be missed entirely. The filtering rules are hand-crafted, not learned, and commit history isn't used yet. What's real: matched, same-task comparisons across two different production coding agents and 100 real GitHub bug-fix tasks.
When you catch your agent pasting whole files, full logs, or entire threads into context, split what it reads into a compact view, a structured index, and a recoverable full copy — then gate what actually enters the prompt by the intent of the call, keeping the full version one lookup away. In this paper's repair agents that cut tokens up to 51.5% and cost up to 36.4%, with the fix rate essentially unchanged.