← All posts

Feeding the Agents: Data Pipelines for RAG and Agentic Retrieval

By MergeRequest · · Data Engineering

Ask an AI assistant about your company’s refund policy and it will answer with total confidence. Whether the answer is right depends on something much less glamorous than the model: the data pipeline behind it. If the pipeline served up last year’s policy, last year’s policy is what the customer hears.

Retrieval-augmented generation, or RAG, and its newer agentic forms are data engineering problems as much as AI problems. Here is what to get right.

1. Start With Clean Sources

Duplicated documents, three versions of the same policy and pages nobody has updated since 2021 all end up in the index. Before embedding anything, decide which source is authoritative, remove duplicates and retire what is out of date.

2. Chunk With the Structure in Mind

Splitting documents every 500 characters is easy and often breaks a table or a step-by-step procedure in half. Split along the document’s own structure: headings, sections, rows. Keep the title and section with each chunk so it still makes sense on its own.

3. Keep Metadata

Source, owner, date, document type and access level should travel with every chunk. Metadata lets the retriever filter, lets the answer cite its source and lets you remove things cleanly later.

4. Freshness Is a Feature

Stale embeddings are one of the most common causes of wrong answers. Update the index when the source changes, not once a quarter. Record when each item was last refreshed so that the agent, and the user, can see how current an answer is.

5. Enforce Access at Retrieval Time

If a user cannot open a document, the assistant must not quote from it. Carry permissions into the index and filter on them for every query. Mask personal data before it is embedded. Getting this wrong is how an internal chatbot becomes a data leak.

Vector search is good at meaning. Keyword search is good at exact terms such as product codes and error numbers. Most production systems use both and then rerank the results.

7. Use Agentic Retrieval Where It Earns Its Keep

In agentic retrieval, the model plans several searches, reads the results and decides what to look up next. It is powerful for complex questions and it costs more in time and money. Most everyday questions are answered perfectly well by plain or hybrid RAG. Save the agentic approach for the ones that need it.

8. Make Retrieval Observable

Log the query, which chunks came back and what filters were applied. When an answer is wrong, this is how you find out whether the model misread good data or was handed bad data.

9. Test Retrieval on Its Own

Build a set of questions with known sources and measure whether the right documents come back. Run it whenever you change chunking, embeddings or the index.

Conclusion

The model gets the attention, but the pipeline decides whether the answer is true. Treat the data that feeds your agents like any other production data product: owned, tested, fresh and access-controlled. That is what our Data Engineering team builds, and it is the base that every reliable AI assistant stands on.

Let’s talk about a project, collaboration or an idea you may have

ACCELERATING INNOVATION SINCE 2021 ·

Contact form