Find the exact line: why our agents search plain text before vectors
The default recipe for letting an AI read your documents is chunk, embed, store in a vector database. It works, but it is often the second step taken first. Here is how we start agent search with plain keyword search over raw files, make every answer quote a line it can prove, and add vectors only when a measured gap says so.
Ask a team how to let an AI answer questions from their own documents and you will usually hear the same recipe. Split every file into chunks. Turn each chunk into an embedding. Store the embeddings in a vector database. At question time, embed the question, pull the closest chunks, and hand them to the model.
That recipe works, and for some jobs it is the right one. But in a lot of projects it is the second step taken first. Before any of it is built, there is a simpler option sitting in the repo: the files themselves, and a search tool that has been fast and reliable for decades.
At Sunrise we start agent search with plain keyword search over raw files. We make every answer quote the exact line it came from. And we only add vectors when a small, honest test shows keyword search missing things that matter. Here is why, and how we decide.
What the agent actually needs
When an agent answers a question from your documents, the answer is only as useful as your ability to check it. "Our refund window is 30 days" is a claim. "Our refund window is 30 days, from policies/refunds.md, line 14" is a claim you can verify in two seconds.
So the retrieval step has one real job: put the right lines in front of the model, with their file and line number attached, so the model can quote them. Not the vaguely related paragraph. The line.
That changes what good search looks like. Similarity scores are a means, not the goal. The goal is a quote that exists, word for word, in a file you own.
Agents are good at searching like people do
Keyword search used to be weak for question answering because a person had to guess the right words on the first try. An agent does not have that problem. It can run a search, read what came back, notice the vocabulary the documents actually use, and search again.
A question like "how long do customers have to get their money back?" might not match the word "refund" on the first pass. The agent tries "money back", sees nothing useful, tries "refund", finds policies/refunds.md, reads the lines around the hit, and answers. Three cheap searches, a few seconds, and the evidence is right there.
The loop costs a little more model time per question than a single vector lookup. In return you get something a similarity score never gives you: the agent can show its work.
What you skip by starting simple
The vector recipe brings a set of decisions and chores that are easy to underestimate.
- Chunking. How big is a chunk? Do you split on headings, paragraphs or a fixed size? Every choice cuts some answers in half.
- Re-indexing. Documents change. Every edit means new embeddings, and a stale index answers from last month's policy without telling anyone.
- A second copy of your data. The vector store is another place your documents live, with its own access rules, backups and deletion story.
- Opaque misses. When a vector search fails, it is hard to say why. When a keyword search fails, you can see exactly which words were tried.
Plain files avoid all four. The source of truth is the folder. Edit a file and the next search sees the edit. Delete a file and it is gone from every answer. Access to the documents is the same access you already manage.
Make every quote provable
Search is half of the job. The other half is making sure the answer does not drift from what the documents say. Our rule is short: every factual claim in an agent's answer quotes a line, with its file path and line number.
That rule is checkable by a script, not just by a careful reader. After the agent answers, we take each quote and confirm it appears word for word at the cited place. A quote that is not in the file gets dropped, and the claim it supported goes with it. A model that paraphrases a policy into something the policy never said is caught before anyone reads the answer.
This is the same instinct behind evidence before merge: an agent's claim counts when it comes with proof a machine can check.
Where keyword search falls short
Keyword search is not the answer to everything, and pretending otherwise would be its own mistake. It struggles in a few predictable places:
- Heavy paraphrase. Users describe a problem in words that never appear in the documents, and the agent cannot guess the bridge.
- Very large collections. Millions of files make every search slower and noisier, and the agent spends more steps sifting.
- Content that is not text. Scanned pages, images and diagrams need a different path entirely.
- Many languages. A question in one language over documents in another breaks keyword matching.
When those show up, vectors earn their place. The question is how you know.
How we decide: measure the gap first
We decide with a small test built from real questions, not a debate. The steps are simple.
- Collect real questions. Pull twenty to forty questions people actually asked, and for each one, write down the exact line that answers it. That pairing is the whole test.
- Run keyword search only. Let the agent search, read and refine as usual. For each question, record whether it found and quoted the target line.
- Read every miss. Label why it missed. Usually the cause is one of three things: the agent gave up too early, the answer was never written down, or the user's words had nothing in common with the document's words.
The labels tell you what to do. If the agent gave up early, fix its instructions so it tries more terms. If the answer was never written down, no retriever will find it, so write the document. Only the third cause, vocabulary mismatch, is a real argument for vectors.
When we do add vectors, they come in as a second retriever, not a replacement. The agent gets hits from both, merged, and the quoting rule stays exactly the same. Then we rerun the same question set. If the found count goes up on the questions that used to miss, the vectors stay. If it barely moves, they come back out, and nobody has to maintain an index for nothing.
How this looks in our own work
Our own research library is plain Markdown in folders, one topic per file. Our agents search it with keyword search, read the surrounding lines, and cite the file path when they bring a finding back. When a library note changes, the next search sees it. There is no index to rebuild and no second copy to keep in sync.
That is the pattern we bring to client builds too. Start with the files you already have. Make every answer quote a line it can prove. Measure what plain search misses with real questions, and add more machinery only where the misses point.
The best retrieval system is the one whose answers you can check, and the simplest one that passes your own questions.