Is Grep All You Need? How Agent Harnesses Reshape Agentic Search
- Publication
- Publication venue not yet verified
- First submitted to arXiv
- arXiv:2605.15184
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{retrievalaugmentedgenerationisgrepallyouneed2026,
title = {{Is Grep All You Need? How Agent Harnesses Reshape Agentic Search}},
author = {Sahil Sen and Akhil Kasturi and Elias Lumer and Anmol Gulati and Vamse Kumar Subbiah},
year = {2026},
eprint = {2605.15184},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2605.15184}
}
If you have used Claude Code, Codex, or Gemini CLI over the past two years, you have probably seen this scene. You ask a question about code, and the agent runs a series of grep searches, reads a few files, then comes back with an answer.
That differs from the standard RAG setup of recent years. The default was to split documents into chunks, convert them into vectors, store them in a vector database, and search by semantic similarity.
So people started asking: if an agent can grep for itself, do we still need vector retrieval?
This is a preprint from PwC in the United States. Its title asks whether grep is enough, but the authors' measurements actually show that the same retrieval tool can perform very differently inside different agent harnesses.
Defining the Problem
The authors argue that earlier retrieval comparisons mostly assume a fixed pipeline in which a retriever finds documents, puts them into the prompt, and has the model answer.
Agents use retrieval differently. They decide what to search for, how many times to search, and whether the results are sufficient. If not, they try another keyword. The harness affects all of this.
The authors therefore ask three questions:
- Which works better across harnesses: grep or vector retrieval?
- Does the answer change when tool results are inserted into the conversation versus written to files for the agent to read?
- How does performance change as irrelevant information grows?
Solving the Problem
The Task: Recover Memories from Long Conversations
The evaluation uses a 116-question subset of LongMemEval.
LongMemEval tests long-term conversational memory. Each question comes with many chat sessions; one or more contain the answer, while the rest are irrelevant distractors. Questions fall into six categories:
| Category | What it tests |
|---|---|
| knowledge-update | Tracking state changes over time |
| multi-session | Combining information across conversations |
| single-session-assistant | Recalling something the assistant said |
| single-session-preference | The user's personal preferences |
| single-session-user | Facts stated by the user |
| temporal-reasoning | Calculating durations, ordering events, and inferring dates |
For an illustrative example of our own, a question might ask, “How many months ago did I last change jobs?” The answer is hidden in one sentence among dozens of chat sessions.
The authors additionally apply their earlier Chronos preprocessing to extract dates and time intervals into structured event records. These are stored alongside the original conversations in separate files for each question. In the authors' view, the study should test finding evidence, rather than reconstructing dates from fragmented conversations.
Two Retrieval Tools
grep loads each question's conversations and event records into memory, matches the raw text with regular expressions, and ranks results by hit count. It needs no embedding model, vector index, or external service.
Vector retrieval embeds each conversation turn and event ahead of time and stores them in a question-specific index. At query time, it embeds the question, retrieves candidates through approximate nearest-neighbor search, reranks them, and returns the top items. The agent chooses .
The paper does not name the embedding model or reranker.
Four Harnesses
- Chronos: The authors' LangChain agent has four search tools—grep and vector versions for conversations and events—enabled or disabled by experimental condition. Its system prompt changes dynamically by question category, with different instructions for temporal reasoning and preferences, for example.
- Claude Code, Codex CLI, and Gemini CLI: The model providers' own command-line agents receive the question and a dynamically generated search strategy, then call wrapped grep or vector-search scripts through bash.
Two Ways to Deliver Results
- Inline (standard): Print search results to standard output or insert them into the conversation as a tool response. The model sees them immediately, but large results occupy context.
- Programmatic (file-based): Write results to a file and return only its location. The model must make another tool call to read or grep that file. This avoids flooding the context, at the cost of an extra step.
Models and Scoring
The five models tested are Claude Opus 4.6, Claude Haiku 4.5, GPT-5.4, Gemini 3.1 Pro, and Gemini 3.1 Flash-Lite.
Following LongMemEval's evaluation procedure, GPT-4o judges correctness from the question, reference answer, and agent response.
Discussion
Experiment 1: Grep, Harness, and Delivery

Each row fixes a model–harness pair. Four columns cross two retrieval methods with two delivery methods.
First, the inline columns. Grep beats vector retrieval in all ten combinations. The largest gap is Chronos with Gemini 3.1 Flash-Lite: 86.2% versus 62.9%. The smallest is Claude Code with Claude Opus 4.6: 76.7% versus 75.0%.
Next, the same model in different harnesses. Claude Opus 4.6 with inline grep scores 93.1% in Chronos but only 76.7% in Claude Code, a 16.4-percentage-point gap. Within Chronos, the grep-versus-vector gap is 9.5 points. Changing the harness can matter as much as changing the retriever, or more.
Finally, the programmatic columns. With file-based delivery, vector retrieval overtakes grep in five of ten combinations. The most dramatic case is Codex CLI with GPT-5.4: inline grep scores 93.1%, tied for best. Under programmatic delivery, grep falls to 55.2%, and vector retrieval reaches only 67.2%.
The authors offer two interpretations:
- LongMemEval rewards literal evidence. Exact dates, counts, preferences, and original statements remain stable strings through tokenization. Grep finds them directly, without passing through embeddings.
- File-based delivery makes the task harder. “Read the tool response” becomes “locate a file, open it, and integrate its contents.” If the extra step is unreliable, accuracy can collapse independently of retrieval quality.
Experiment 2: What Happens with More Distractors?
The second experiment sets the number of sessions visible per question to 5, 10, 20, 30, or the full 39–66. Answer-containing sessions are always retained; the remaining slots are filled with distractor sessions for that question.
People usually assume that grep suffices for small data, while larger data needs semantic search.
The results are less simple:
- The curves are not monotonic. For Chronos with Opus, grep drops from 90.5% at s20 to 85.3% at s30, then rises to 89.7% with the full data.
- Vectors often do better with little data. At s5, Chronos's grep scores range from 83.2% to 89.7%, versus 87.9% to 94.0% for vectors.
- The winner depends on the harness. Claude Code with Opus or Haiku favors grep in every setting. Gemini CLI with Gemini 3.1 Pro favors vectors in every setting, reaching 89.7% versus 78.5% with full data. Chronos alternates winners across conditions.
The authors also note that distractor sessions are resampled for each session limit. A mid-curve fluctuation such as “30 is easier than 20” may come from that particular distractor sample. Interpret these curves with the effects of random sampling in mind.
The Two Experiments' Numbers Do Not Match
One issue needs particular attention.
The full-data settings in Experiments 1 and 2 appear to use the same 116 questions, distractors, and inline delivery, yet their numbers differ substantially:
| Model and harness | Retrieval | Experiment 1 (Table 1) | Experiment 2 full (Tables 2, 3) |
|---|---|---|---|
| Opus + Claude Code | grep | 76.7 | 94.0 |
| Haiku + Claude Code | grep | 55.2 | 81.9 |
| Opus + Chronos | Vector | 83.6 | 92.2 |
| Gemini 3.1 Pro + Gemini CLI | grep / vector | 81.9 / 75.0 | 78.5 / 89.7 |
The last row even reverses the winner, with grep leading in Experiment 1 and vectors in Experiment 2. The paper does not explain the setup difference. Experiment 2 also lacks Codex rows, which the authors mark as pending.
Strictly speaking, the conclusion that grep consistently outperforms vectors holds only for Experiment 1's inline setting.
The Authors' Own Boundaries
The limitations section states that these conclusions are tied to long-term conversational-memory QA. Evidence in these tasks is often a sentence that can be found verbatim, favoring literal matching. Results may differ for paraphrased summaries of scientific literature, image-heavy documents, or code semantics, where evidence rarely appears in exactly the same wording.
The authors explicitly avoid claiming that grep universally beats vector retrieval. They claim that grep can win end-to-end comparisons on the tasks and corpus they studied.
Conclusion
The paper's title asks whether grep is enough, and judging from the experiments, for this task and these settings it often is, but that depends on who uses it and how.
- Inline grep wins all ten combinations. Long-conversation evidence is often a string that can be found verbatim, exactly grep's strength.
- The harness matters as much as the retrieval method. The same Claude Opus 4.6 differs by 16.4 percentage points between the homemade harness and Claude Code.
- File-based delivery reshuffles the winners. Grep with Codex and GPT-5.4 falls from 93.1% to 55.2%; vectors lead in five of ten combinations.
- There is no fixed winner as distractors grow. Results vary with harness, model, and sampling.
These findings come from 116 questions, single runs, an unnamed embedding model, and experiments with conflicting numbers. They suggest directions to validate yourself, rather than a settled verdict.
In their conclusion, the authors recommend evaluating the retrieval mechanism, harness orchestration, and result-delivery path together as one system.
To compare grep with vectors, run the comparison inside your own agent.