DEV Community

Cover image for Agent reading every files to answer one simple question?
Le Huy Hiep
Le Huy Hiep

Posted on

Agent reading every files to answer one simple question?

My knowledge base grew across thousands of markdown files. Finding one fact meant reading whole files. Keyword search found words, not meaning. And reading whole files burns tokens: tens of thousands of tokens to surface one fact. The real metric is not storage. It is tokens per answer.

Why not the usual tools?

  • grep finds the file, but you still read it. Cost unchanged.
  • A cloud vector DB sends private notes out and adds infra for a 2 MB corpus.
  • Semantic-only search cannot do exact filters.

What I built: a local-first retrieval layer.

  1. SQLite FTS5 index: instant keyword search, exact filters, real file:line references.
  2. Local ONNX embeddings (384-dim): semantic ranking. Every hit points at a real file.
  3. One-command rebuild. The index is derived, so it never goes stale.

Result: 2,000 chunks, one CLI, zero servers. An answer now costs a few hundred tokens, not a sweep through thousands of files.

Start deterministic. Add semantic where keywords fail. Rebuild often.

Top comments (0)