Your agent is debugging a production incident. The log line says ECONNREFUSED 127.0.0.1:5432 and a config key DATABASE_POOL_SIZE. Vector search will not save you here. You need an exact string match, a file path, and a version pin.
That gap is why Direct Corpus Interaction (DCI) keeps showing up in 2026 agent research. Instead of retrieving pre-chunked embeddings, the agent treats the corpus as a live environment and searches it with the same tools a human engineer would: rg, grep, find, head, and shell pipelines.
I wrote about grep beating vector search inside real agent harnesses in Grep beat vector search in agentic retrieval. This post is the next layer: what happens when you train a compact model to grep well, and how I would wire DCI into a production stack without throwing away semantic retrieval entirely.
Why RAG filters out the evidence agents need
Classic RAG chunks documents, embeds the chunks, and returns top-k similarity hits before the model reasons. That pipeline is fine for static FAQs and broad semantic questions. It is brittle for software engineering and IT ops.
Agentic search needs plan revision. The agent sees partial evidence, forms a hypothesis, and searches again. Error codes, numeric thresholds, semver constraints, and bridge entities across files are lexical problems. If the vector index drops a chunk before the reasoning loop starts, no amount of downstream thinking recovers it.
Beyond Semantic Similarity: Rethinking Retrieval for Agentic Search via Direct Corpus Interaction frames this as an interface design problem. Retrieval quality depends on the resolution of how the model touches the corpus, not only on embedding quality.
| RAG pipeline | DCI loop |
|---|---|
| Chunk + embed offline | Read raw files as they exist now |
| Single top-k retrieval step | Multi-step shell commands with feedback |
| Semantic similarity | Exact lexical constraints |
| Evidence filtered early | Agent can widen or narrow each hop |

What GrepSeek adds beyond "give the model a terminal"
DCI is not new as an idea. Researchers have shown that prompting strong closed models to orchestrate grep over a corpus works on hard retrieval benchmarks. The operational problem is cost and latency. Some prompt-only setups need up to an hour per query on large corpora.
GrepSeek: Training Search Agents for Direct Corpus Interaction trains a compact open-weight agent (Qwen3.5-9B) to search a ~14 GB Wikipedia-scale corpus with shell commands. No embedding index. Just the raw text and a learned search policy.
The headline engineering pieces:
- Two-stage training so RL does not collapse into degenerate broad greps
- Sharded-parallel execution that stays byte-exact with sequential grep but runs up to 7.6× faster
- Strong multi-hop numbers on HotpotQA, 2WikiMultihopQA, and MuSiQue where dense retrievers often conflate entities
On their hardware (single A100, 32 CPU cores), average search latency drops from 5.39 seconds to 0.71 seconds with the fast engine. End-to-end query latency lands around 8.6 seconds including reasoning and tool rounds.
That is the difference between a research demo and something you might actually put behind an internal search agent.
How GrepSeek learns to grep without cheating on the answer
Naive RL on corpus-wide shell access tends to blow up. Agents issue overly broad commands, pull megabytes into context, and training runs hit RAM limits even on 1 TB hosts.
GrepSeek stabilizes learning with a cold-start pipeline before GRPO:
- Answer-aware Tutor decomposes the question and builds a backward chain of verified shell commands from the gold answer
- Answer-blind Planner assembles a forward trajectory that matches what the agent would see at inference time
- SFT on verified trajectories teaches concise, causally grounded commands
- GRPO refines task-oriented search behavior with group-relative rewards
The Tutor enforces an answer-leak rule during backward command generation. Retrieval terms cannot include the target entity or its aliases. Without that mask, backward construction cheats by grepping the answer string, which teaches fantasy retrieval behavior.

The action space includes rg, grep, find, sed, awk, head, and friends. In practice the trained agent mostly relies on rg and head, which matches what I see in production coding agents that ship ripgrep as the default search tool.
If you want to run the released stack yourself, the authors open-sourced code, data, and checkpoints on GitHub (alirezasalemi7/grepseek) with a Colab-friendly demo notebook.
Where DCI wins and where it still loses
GrepSeek reports the strongest overall token F1 and exact match across seven open-domain QA benchmarks in their suite. Gains are largest on multi-hop sets where dense retrieval smears distinct entities into semantically similar chunks.
Pure lexical search still struggles when surface forms vary wildly or questions are semantically broad with no anchor string. The paper is explicit about that limitation. DCI is a complement, not a universal replacement for embeddings.
That matches what I see shipping agents for clients:
- Tickets, logs, CRM notes, chat exports: grep-first or BM25-first, with the agent in the loop
- Policy PDFs, support articles, compliance libraries: semantic retrieval still earns its seat
- Code repos: structural tools (tree-sitter maps, LSP) plus grep, not a standalone vector index
The hybrid stack I would ship in 2026
AlphaSignal's Sunday deep dive on this topic (adapted from Ben Dickson's writeup) lands on a practical default I agree with: do not stuff the whole repo into a million-token window every turn, and do not grep the entire enterprise corpus on every hop without guardrails.
For large corpora, use a layered interface:
| Layer | Role | Example tools |
|---|---|---|
| Semantic retrieval | Broad candidate discovery when intent is fuzzy | Dense/BM25 index, hybrid retriever |
| DCI verification | Exact constraints, lateral expansion, version checks | rg, find, head, filtered pipelines |
| Harness policy | Inline vs file delivery, retry rules, output caps | Agent shell + logging |

Semantic search finds an anchor document when the user asks something vague like "database connection instability after deploy." Terminal tools verify the exact error string, trace neighboring configs, and confirm pool size values before the agent commits to a root cause.
This is also how I think about data architecture going forward. Corpora need to be organized for agents that inspect raw files, not only for humans clicking search results. Folder layout, stable IDs in logs, and predictable config paths matter because your agent will navigate them like a new hire with a terminal.
What I would benchmark before you buy more retrieval infrastructure
If you are evaluating DCI or GrepSeek-style search for an internal agent, measure the harness you will actually run, not isolated recall@k:
- End-to-end task accuracy on real incident tickets or support threads, not offline chunk matching alone
- Latency per search hop with and without a sharded execution layer (network-mounted corpora punish naive grep)
- Context bloat from oversized tool output (cap lines, pipe to
head, log every command) - Inline vs file tool delivery (see the harness effects in my grep vs vector harness post)
- Hybrid ablation: semantic-only, lexical-only, and semantic-then-DCI on the same eval set
Tools worth wiring into that eval harness:
- ripgrep for fast lexical search
- Claude Code docs for a reference terminal-native agent shell
- GrepSeek on Hugging Face Papers for the training recipe and benchmarks
Takeaway
Vector embeddings are a snapshot. Terminal tools read the corpus as it exists right now. GrepSeek shows you can train a small open model to wield that interface efficiently, with engineered execution that makes million-document grep practical.
The bigger lesson for applied AI shipping: retrieval is an interface design problem. Give agents higher-resolution access to the corpus, teach them when to grep versus when to embed, and measure inside the harness that bills your API account.
If you want help designing a hybrid agentic retrieval stack (and an eval that survives the demo), book a free discovery call.

