---
title: "The grep nightmare: your coding agent pays to get lost"
description: "Grep-heavy turns took 63% of our coding agent spend and missed the right code 1 in 3 times. Papr Work adds on-device search under grep, for code and chats."
url: https://www.papr.ai/blog/coding-agent-grep-cost
author: "Papr"
published: 2026-12-02
updated: 2026-12-02
---

# The grep nightmare: your coding agent pays to get lost

> **In short:** Coding agents find code by guessing names and running grep. On our own repo that took 63% of agent spend and missed the right code 1 in 3 times. Papr Work now adds up to three files grep missed, found by a small code model on your Mac, and searches your old chats and docs the same way. It found the needed file in 46 of 50 hand-graded misses.

![grep for 'copy app files' returns 0 matches, but installBundle() in server/installer.ts does exactly that](https://rcbwlxuma5nuwt7a.public.blob.vercel-storage.com/blog/coding-agent-grep-cost/cover.png)

Coding agents find code by guessing a name and running grep. On our own repo, that coding agent grep cost was 63% of our agent spend, and grep missed the right code 1 in 3 times. So Papr Work now adds up to three files grep missed under the agent's own grep, found by a small code model that runs on your Mac. In our replay of 50 hand-graded misses, it showed the needed file 46 times.

We also added the same search for your old chats and documents, and we measured both with two public benchmarks we built for this: Code Bench and Context Bench. Here is what one miss looks like, what it costs, and what we changed.

## One question, $2.29, zero answers

The question was simple: "How are app files copied when someone installs or forks an app?" Our agent guessed at names like `copyAppFiles` and `cloneAppFiles`, and grep returned one match, a code comment. Then it ran 11 more searches, made 41 tool calls and read 288,020 characters. It found the right answer zero times.

Then it answered anyway: "Installs don't copy App Files." It reached that from an absence of matches. The agent got lost. The lab got paid.

![Receipt for one question: 12 searches, 41 tool calls, $2.29, zero answers](https://rcbwlxuma5nuwt7a.public.blob.vercel-storage.com/blog/coding-agent-grep-cost/receipt.png)

If you are a GTM engineer, this is your repo too: enrichment scripts, CRM syncs, lead routers and webhook handlers that grew faster than their docs. Every agent session starts there as a new hire.

## Where the coding agent grep cost goes

We measured our own Papr Work chats from August to November 2026. Across 5,268 tool-using turns we spent $10.9K on 100,602 tool calls. Search was 28% of those calls and file reads were 21%, so almost half of all calls went to finding code. A turn that searches uses a median of 5 searches and 4 reads to find one answer.

Turns with five or more searches were 29% of turns and 63% of spend ($6,853). In an older window of 7,213 turns, a median turn with five or more greps cost $1.65. A turn with no grep cost $0.56. Search-heavy turns are also the bigger tasks, so these numbers show where the spend sits, not a controlled saving.

![Bar chart: search-heavy turns were 29% of turns and 63% of spend](https://rcbwlxuma5nuwt7a.public.blob.vercel-storage.com/blog/coding-agent-grep-cost/spend.png)

## A miss does not stop the agent

We graded 251 real greps from our agent on our own repo by hand, from September to November 2026. In 91 of them the right code was not in the results. That is 36%, or 1 in 3.

Of 90 misses, 85 went on to write code. We reworked code built on a miss within a week 65% of the time (24 of 37), against 48% when the search hit (41 of 85). The sample is small, but the pattern is clear: a miss rarely ends with "I could not find it." It ends with confident code in the wrong place.

![Chart: 91 of 251 searches missed; code built on a miss was reworked more often](https://rcbwlxuma5nuwt7a.public.blob.vercel-storage.com/blog/coding-agent-grep-cost/misses.png)

## Why agents still grep

Frontier labs sell tokens, so nothing in their business pays them to cut the tokens a task needs. A nine-call search bills nine calls, and a miss bills the rewrite and then the rework. I don't think anyone designed it this way, but nobody is paid to fix it either.

Grep is also easy to train on. Every repo has it, the output is plain text, and a grep that returns something looks like progress. It seems to work until someone digs in and counts the rewrites, and the misses that turn into confident wrong answers. We only saw it because we graded searches one by one.

Any frontier model runs the same loop, because the loop comes from the agent design. So the fix falls to the harness, the layer that runs the tools. That is where we built it.

## What we built: grep, plus three pointers

When the agent runs grep in Papr Work, it gets grep's output untouched, plus a short block of up to three files this search may have missed. The agent sees better evidence in the place it already looks.

Our code model, papr-embed-code-1-0.6b, runs on your Mac on the Neural Engine and finds the top 20 candidates. A code graph adds each one's definition, callers, imports and docs. Jev, our ranking model, then orders them against the user's request. The top three become the pointers.

![Grep output with an added block of three file pointers grep missed](https://rcbwlxuma5nuwt7a.public.blob.vercel-storage.com/blog/coding-agent-grep-cost/grep-block.png)

We replayed the 50 hand-graded misses we could reproduce, plus 25 controls. With Jev, the results showed the needed file in 46 of 50 misses, and local and cloud runs matched. The needed file was in the three pointers 41 times, against 33 with a local formula alone. The controls held at 17 of 25, so searches that already worked were not hurt.

The search query matters as much as the model. A grep pattern like `lead\b` says little about intent, so the shipped build adds the user's request to the query. On the same misses, that moved the on-device search alone from 29 to 41 needed files in its top 10.

## Your chats and docs get the same search

Agents also need to find something said 300 messages ago, or a line in a doc. For Context Bench we wrote 94 questions with hand-written answers over our own chats and 30 documents. Grep put the answer in its top 5 for 54 of them, and our cloud memory search found 39.

Keyword search won among single methods, because chat facts hold exact tokens like PR numbers, IPs and dollar amounts. So the shipped search fuses keyword search with the same on-device 0.6B model, and Jev reranks the top 20. It returns the whole message, not a fragment. That one choice took "bring back that earlier message" from 0 of 12 to 11 of 12.

![Bar chart: hits in the top 5 out of 94 memory questions, by search method](https://rcbwlxuma5nuwt7a.public.blob.vercel-storage.com/blog/coding-agent-grep-cost/memory.png)

The code that ships in Papr Work scores 80, 83 and 88 at top 3, 5 and 10. It answers when the agent greps your documents or chat history, and next to the cloud results in memory search. The index lives on your Mac and reads your chats without changing them.

## The decisions behind it

**Hook grep, don't add a tool.** In 49 of our local Cursor agent transcripts, its agent ran 3,294 greps. It called Cursor's own semantic search, which is good, only 2 times. So we put the help inside grep; the trade-off is that we only help when the agent greps.

![Chart: Cursor's agent ran 3,294 greps and 2 semantic searches](https://rcbwlxuma5nuwt7a.public.blob.vercel-storage.com/blog/coding-agent-grep-cost/cursor.png)

**A small model on your Mac.** We chose the 0.6B model over our 4B because it runs on device in about 1.1 GB and keeps your code on the machine. The 0.6B alone finds fewer misses than the 4B, and the code graph and Jev close most of that gap. Our best earlier setup, a 4B embedding with an 8B GPU reranker, found 47 of 50; this path finds 46 with no GPU.

**Three pointers, not a score cutoff.** An earlier design showed a pointer only when Jev was at least 0.7 confident, and that gate hid the right file in 31 of 50 misses. Now Jev picks the three best files for the request. Offline or past 1.5 seconds, Papr Work falls back to a local formula, and grep still answers.

**Add, never replace.** Grep's output never changes, so exact-match searches lose nothing. The pointer block also stays quiet unless it adds a file grep did not already find, and it skips build output and one-file greps.

## What you can do now

- [Download Papr Work](https://papr.ai/download) for Mac. Code search under grep and chat and doc search shipped in [Papr Work v2.7.13](https://github.com/Papr-ai/paprwork/releases/tag/v2.7.13).
- Read or build the source on [GitHub](https://github.com/Papr-ai/paprwork), including the Code Bench and Context Bench harnesses.
- Run the model yourself: [papr-embed-code-1-0.6b on Hugging Face](https://huggingface.co/papr-ai/papr-embed-code-1-0.6b), with a [CoreML build](https://huggingface.co/papr-ai/papr-embed-code-1-0.6b/tree/main/coreml) for the Apple Neural Engine and an [ONNX build](https://huggingface.co/papr-ai/papr-embed-code-1-0.6b/tree/main/onnx) for any machine.
- Use the larger [papr-embed-code-1-4b](https://huggingface.co/papr-ai/papr-embed-code-1-4b), or either size through the Papr embeddings API at memory.papr.ai/v1/embeddings.

## Questions

### Why do coding agents use grep instead of semantic search?

Grep is fast, exact and in every repo, and it is easy to train on. In our view nobody is paid to cut the tokens it wastes, since labs bill by the token. The agent must guess the right name first, and in our hand-graded sample 1 in 3 searches missed.

### How much does grep cost an AI coding agent?

In our Papr Work chats from August to November 2026, turns with five or more searches were 29% of turns and 63% of spend. Those turns are also the bigger tasks, so this shows where spend concentrates, not a controlled saving.

### How do I reduce Claude Code or Codex token usage on code search?

Give the agent search that finds the right file on the first try. In Papr Work the agent keeps its grep and gets up to three extra file pointers. On 50 replayed misses, the needed file showed up 46 times.

### Does my code leave my machine?

The code model and both indexes stay on your Mac. Cloud sync uploads vectors only. When you're signed in and online, Jev gets your request plus each top candidate's path and a short snippet; offline or with Jev off, your code stays local.

### Can I run papr-embed-code on a Mac Neural Engine or with ONNX?

Yes. The 0.6B model on Hugging Face ships a CoreML build for the Apple Neural Engine and an ONNX build for other machines. A 4B model is there for higher accuracy.

---

Source: [The grep nightmare: your coding agent pays to get lost](https://www.papr.ai/blog/coding-agent-grep-cost) on the Papr Blog. Papr builds context intelligence for AI agents and Papr Work, a desktop app where AI builds and runs small apps for go-to-market teams.
