Artificial Intelligence

Normal RAG or agentic RAG: when it pays for the AI to search again

Team Nippysoft
• • 18 min read
Normal RAG or agentic RAG: when it pays for the AI to search again

An assistant that answers from your company's documents can work in two ways. Normal RAG searches once, hands the model what it found and answers. Agentic RAG plans the search, searches, checks whether what it found is enough and, if something is missing, searches again before answering. The second one answers questions the first leaves half answered, but it makes more calls, takes longer and uses more tokens. This post compares both with one example, gives a simple rule for choosing and explains why an agent needs a search limit. All the example code, with its tests, can be downloaded from the rag-vs-agentic-rag repository at NippysoftLabs.

First, the acronyms. RAG (retrieval-augmented generation) means that, before answering, the program searches your documents and hands the model what it found. The model, or LLM (large language model), is what sits behind ChatGPT, Claude or Gemini. An agent is a model that uses tools in a loop and decides the next step itself; here the tool is the search. The index is where documents are searched: in a real system it's usually a vector database, which searches by similarity of meaning rather than exact words, and in the example it's a keyword search. A token is the piece of text each model call is measured and billed in.

The example is the same throughout the post: the manuals of a fictional company, 11 short pages, and four questions. An easy one, answered by one page: how many vacation days a full-time employee gets per year. Another needs two searches: what number to call if the VPN, the secure connection to the company network, fails outside office hours. The VPN page says to contact the infrastructure on-call team, and the number is on another page. One isn't in the manuals: what visitors pay for parking. And the last one chains four pages, to test the limit: what number to call to replace a lost badge. The model is simulated and follows fixed rules, so every run gives the same figures. The questions and manuals are in English, like the rest of the code.

If you're in a hurry, here's the short decision. The full table, with the reason for each row, is at the end:

If your questions…Use
Are answered by one pageNormal RAG
Sometimes need several pages put togetherNormal RAG with one check (adaptive)
Get different results depending on how the first search is plannedAgentic RAG

And if you use an agent, always give it a search cap.

Normal RAG: search once and answer

What it is and what it's for

Normal RAG does three things, once each: it searches the index, hands the model the pages it found, and the model answers from them. That's one search and one model call. It lets the model answer from documents it doesn't know and say where the answer came from.

Why it came about

A model only knows what it learned in training. It doesn't know your manuals, doesn't notice when they change and can't say where it got something. In 2020, Lewis and others proposed joining the model's memory with an index of documents that can be updated: the model writes its answer from the passages it retrieves.

An everyday example

It's an open-book exam: before answering, you look up the right page in the book and answer from it.

The code

Before, the model answers without the manuals. The simulated one knows nothing about the company, so it can't answer:

/// <summary>
/// BEFORE RAG: the model answers from what it learned in training, without the company's manuals.
/// The simulated model has no training data, so it cannot answer anything about the company.
/// </summary>
public static class NoRetrieval
{
    public static RagResult Ask(string question)
    {
        var model = new SimulatedModel();
        var (answer, sources) = model.Answer(question, []);
        return new RagResult(answer, sources, Searches: 0, model.Calls);
    }
}

After, normal RAG searches for two pages and calls the model once:

/// <summary>Normal RAG: search once, answer once.</summary>
public sealed class SimpleRag
{
    private readonly ManualIndex _index;
    private readonly int _top;

    public SimpleRag(ManualIndex index, int top = 2)
    {
        ArgumentNullException.ThrowIfNull(index);
        ArgumentOutOfRangeException.ThrowIfNegativeOrZero(top);
        (_index, _top) = (index, top);
    }

    public RagResult Ask(string question)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(question);
        var model = new SimulatedModel();
        var passages = _index.Search(question, _top);
        var (answer, sources) = model.Answer(question, passages);
        return new RagResult(answer, sources, Searches: 1, model.Calls);
    }
}

The demo shows both versions with the easy question:

Q: How many vacation days do full-time employees get per year?
  no retrieval  searches 0, model calls 1, steps 1, tokens in 37 / out 9
                I could not find this in the manuals.
  normal RAG    searches 1, model calls 1, steps 2, tokens in 100 / out 18
                Full-time employees get 15 vacation days per calendar year. [hr-vacation]

With one search and one call, normal RAG answers that it's 15 days per year and cites the hr-vacation page. The call reads 100 tokens and writes 18.

What guards it

In production, the signal is the citation: every answer says which page it came from, so an answer with no citation, or with the wrong page, shows.

What it doesn't guard: the search is by keywords. If the question uses a synonym, like VPN is down at night, or comes in another language, the index brings back the wrong sentence of the VPN page, the office-hours one, and normal RAG gives it as the answer, with confidence. A manual can also carry text that gives the model orders: the simulated one ignores it, but a real one may follow it, and OWASP calls this indirect injection. And in the example everyone sees every manual; a real system filters by user before handing passages to the model.

Lewis and others put it this way in their 2020 paper: the ability of pre-trained models to "access and precisely manipulate knowledge is still limited", and "providing provenance for their decisions and updating their world knowledge remain open research problems".

Agentic RAG: check and search again for what's missing

What it is and what it's for

Agentic RAG turns the search into a loop. The model writes the query, the program searches, the model checks whether what came back answers the question and, if something is missing, asks for another search for it. When it's enough, it answers. It's for questions whose answer is spread across several pages.

Why it came about

Some questions can't be solved with one search, because what to look for depends on what was already found. Trivedi and others showed it with multi-step questions, and those questions, called multi-hop, even have their own datasets, such as HotpotQA. The 2025 review by Singh and others calls agentic RAG putting autonomous agents into the RAG flow, as opposed to fixed-flow systems. There are variants, such as Self-RAG, which searches only when needed instead of always bringing the same number of passages; this post doesn't go into them.

An everyday example

You ask at reception for the night support number and they tell you the on-call team handles that. A person doesn't stop there: they ask for the on-call team and come back with the number.

The code

Before, normal RAG finds the VPN page and stops halfway: it says who to call, but not the number that was asked for. After, the agentic version checks, sees the number is missing and searches again for the on-call team:

Q: What number do I call if the VPN fails outside office hours?
  no retrieval  searches 0, model calls 1, steps 1, tokens in 38 / out 9
                I could not find this in the manuals.
  normal RAG    searches 1, model calls 1, steps 2, tokens in 98 / out 20
                If the VPN fails outside office hours, contact the infrastructure on-call team. [it-vpn]
  agentic RAG   searches 2, model calls 4, steps 6, tokens in 384 / out 55
                If the VPN fails outside office hours, contact the infrastructure on-call team. The infrastructure on-call team answers at internal extension 4410, every day of the year. [it-vpn, it-oncall]

This is the agentic loop. It stops for four reasons, covered in the last section:

internal RagResult Continue(string question, SimulatedModel model, string query, List<Document> passages, int searches)
{
    var ran = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
    StopReason stop;
    while (true)
    {
        if (searches >= _maxSearches) { stop = StopReason.Limit; break; }
        // The same query again would return the same passages.
        if (!ran.Add(query)) { stop = StopReason.RepeatedQuery; break; }
        searches++;
        foreach (var d in _index.Search(query, _top))
            if (!passages.Contains(d)) passages.Add(d);

        var verdict = model.Check(question, passages);
        if (verdict is Verdict.SearchAgain again) { query = again.Query; continue; }
        stop = StopOf(verdict);
        break;
    }
    return Finish(question, model, passages, searches, stop, _maxSearches);
}

internal static StopReason StopOf(Verdict verdict) =>
    verdict is Verdict.Enough ? StopReason.Answered : StopReason.NotInManuals;

/// <summary>
/// Writes the answer and says in it when information is missing, so the reader of the answer sees
/// what the StopReason says: incomplete (limit, repeated query) or not in the manuals.
/// </summary>
internal static RagResult Finish(string question, SimulatedModel model, List<Document> passages, int searches, StopReason stop, int maxSearches)
{
    var (answer, sources) = model.Answer(question, passages);
    answer = stop switch
    {
        StopReason.Limit => answer + $" (Stopped at the search limit of {maxSearches}; this answer may be incomplete.)",
        StopReason.RepeatedQuery => answer + " (The manuals point back to a search already made; this answer may be incomplete.)",
        // The best sentence does not answer the question: say so first, then show what was closest.
        StopReason.NotInManuals when answer != SimulatedModel.NotFound => $"{SimulatedModel.NotFound} Closest passage: {answer}",
        _ => answer,
    };
    return new RagResult(answer, sources, searches, model.Calls, stop);
}

The sequence of calls is plan, check, check and answer: 2 searches and 4 calls to reach extension 4410:

public void After_agentic_RAG_searches_again_and_finds_the_number()
{
    var r = new AgenticRag(Index).Ask(TwoSearches);

    Assert.Contains("internal extension 4410", r.Answer);
    Assert.Equal(["it-vpn", "it-oncall"], r.Sources);
    Assert.Equal(["plan", "check", "check", "answer"], r.Calls.Select(c => c.Kind));
    Assert.Equal((2, 4, 6), (r.Searches, r.ModelCalls, r.Steps));
}

What guards it

The agentic answer cites both pages, it-vpn and it-oncall, so you can see which search brought each part. What it doesn't guard: the check in the example is a fixed rule, not a model. It asks for another search when the question asks for a number and the passage found doesn't have one but sends you to contact someone. And it's easy to fool: it takes any digit as the number, so if you ask what number to call about a lost laptop, the 24 in within 24 hours is enough. A real model checks differently, and it also gets things wrong. With a synonym, like VPN is down at night, the check sees the number is missing and answers that it isn't in the manuals, with the closest passage, even though the extension is on another page. With the question in Spanish it doesn't notice and answers wrong, with confidence. If the question holds two questions in one, the agentic version answers only one part.

Trivedi and others explain it: "one-step retrieve-and-read approach is insufficient for multi-step QA", because "what to retrieve depends on what has already been derived". In HotpotQA, the questions "require finding and reasoning over multiple supporting documents to answer". And the review by Singh and others defines agentic RAG as "embedding autonomous AI agents into the RAG pipeline".

What you gain and what you pay

What it is and what it's for

The agentic version wins on spread-out questions and pays on all of them: more model calls, more tokens and more waiting, because searches and calls run one after another. This table gathers the example's figures. Steps are searches plus calls, and tokens were counted with the o200k_base tokenizer on the text of each call:

QuestionApproachSearchesCallsStepsInput / output tokensResult
EasyNormal112100 / 18Correct
EasyAgentic134229 / 27The same
EasyAdaptive123204 / 20The same
VPNNormal11298 / 20Incomplete, no number
VPNAgentic246384 / 55With the number
VPNAdaptive235358 / 50With the number
ParkingNormal11233 / 9Not in the manuals
ParkingAgentic13491 / 13Not in the manuals
ParkingAdaptive12370 / 10Not in the manuals
BadgeNormal11278 / 16Incomplete, no number
BadgeAgentic358459 / 65Stops at the limit of 3 and warns
BadgeAdaptive347435 / 62Stops at the limit of 3 and warns

On the easy one, the agentic version makes 3 calls and reads 229 tokens to give the same answer that normal RAG gives with 1 call and 100 tokens. On the VPN one, only the agentic and the adaptive versions, the latter covered in the next section, reach the number: 4 calls and 384 input tokens against 1 call and 98. These are figures from this example with a simulated model. They're for comparing approaches, not for estimating a real system, and there are no timings because the repo doesn't measure time. On all four questions, the adaptive version reaches the same answer as the agentic one with one call fewer.

Why it came about

It's the price of letting the model decide how many steps to take. Anthropic, which builds agents, says so in its guide, and recommends starting simple.

An everyday example

A taxi that stops to ask every time it's unsure gets to a hard address better. To a well-known address it arrives the same as one that drives straight there, but it takes longer and charges more.

The code

Normal and agentic RAG on the same easy question:

public void On_the_easy_question_agentic_RAG_pays_more_for_the_same_answer()
{
    var simple = new SimpleRag(Index).Ask(Easy);
    var agentic = new AgenticRag(Index).Ask(Easy);

    Assert.Equal(simple.Answer, agentic.Answer);
    Assert.Equal((1, 3, 4), (agentic.Searches, agentic.ModelCalls, agentic.Steps));
    Assert.Equal((100, 229), (simple.InputTokens, agentic.InputTokens));
}
Measure your questions in calls and tokens before choosing: if the agentic version doesn't change the answer, it only changes the bill.

What guards it

In production, the signal is the usage the provider returns with each call: added up per question, it tells you what each approach costs on your questions. What it doesn't guard: the real cost depends on each model's price and tokenizer, and a real system adds tokens for the message structure. The example counts only the text put together for each call.

Anthropic puts it this way: "Agentic systems often trade latency and cost for better task performance, and you should consider when this tradeoff makes sense". And in the same guide: "For many applications, however, optimizing single LLM calls with retrieval and in-context examples is usually enough."

A simple rule for deciding

What it is and what it's for

The example's rule is this: start with normal RAG, check once whether what it found is enough, and only if something is missing move to the agentic version, keeping what was already found. If almost all your questions are answered by one page, normal RAG is enough. If many chain documents, such as who to call or what the policy cited by another one says, searching again earns its cost. It's a rule from this repo, not from a standard.

Why it came about

Research reached the same place by another road. Adaptive-RAG, by Jeong and others (NAACL 2024), points out that multi-step methods overspend on simple questions and that single-step ones fall short on complex ones. Its answer is a classifier, a smaller model trained to predict how complex each question is before searching. The repo does something else: it searches once and checks afterwards. It's an approximation, not the paper's method.

An everyday example

In a hardware store, the clerk answers the easy things from memory and only goes to the stockroom when memory isn't enough.

The code

Before, always agentic: 3 calls even when the question is easy. After, the rule in code:

/// <summary>
/// The decision rule in code: try normal RAG first, ask the model once whether the passages are enough,
/// and only then go agentic, keeping what was already found.
/// </summary>
public sealed class AdaptiveRag(ManualIndex index, int maxSearches = 3, int top = 2)
{
    private readonly AgenticRag _agentic = new(index, maxSearches, top);
    private readonly int _maxSearches = maxSearches;

    public RagResult Ask(string question)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(question);
        var model = new SimulatedModel();
        var passages = index.Search(question, top).ToList();
        var verdict = model.Check(question, passages);
        if (verdict is Verdict.SearchAgain again)
            return _agentic.Continue(question, model, again.Query, passages, searches: 1);

        return AgenticRag.Finish(question, model, passages, searches: 1, AgenticRag.StopOf(verdict), _maxSearches);
    }
}

This is what it pays in each case:

public void Adaptive_RAG_pays_one_extra_call_on_easy_questions_and_goes_agentic_only_when_needed()
{
    var easy = new AdaptiveRag(Index).Ask(Easy);
    var hard = new AdaptiveRag(Index).Ask(TwoSearches);

    Assert.Equal(["check", "answer"], easy.Calls.Select(c => c.Kind));
    Assert.Equal((1, 2, 3), (easy.Searches, easy.ModelCalls, easy.Steps));
    Assert.Contains("internal extension 4410", hard.Answer);
    Assert.Equal(["check", "check", "answer"], hard.Calls.Select(c => c.Kind));
    Assert.Equal((2, 3, 5), (hard.Searches, hard.ModelCalls, hard.Steps));
}

On the easy one it makes 2 calls, check and answer: one more than normal RAG, and just over twice the input tokens, 204 against 100. That's the price of the check. On the VPN one it makes 3, check, check and answer, and reaches the same number as the agentic version with one call fewer, because it doesn't plan the first search: it searches with the question as is.

What guards it

In production, the signal is how many questions move to agentic: if it's almost all of them, check whether planning the first search changes what you find; in this example, adaptive costs less than agentic even when it has to search again. If it's few, the check costs little. What it doesn't guard: the check is the same fixed rule as in the agentic version, so if it doesn't notice something is missing, the adaptive version answers like normal RAG.

Jeong and others describe the problem: multi-step methods "handle simple queries with unnecessary computational overhead", and single-step ones "fail to adequately address complex multi-step queries". Anthropic sums it up in one recommendation: "we recommend finding the simplest solution possible, and only increasing complexity when needed".

A loop limit so it doesn't search forever

What it is and what it's for

An agent decides itself how many searches to make. The limit is a cap on searches plus some exit rules, so it stops even when it isn't satisfied, and says so when it stopped without finishing.

Why it came about

If what it's looking for doesn't exist, the agent may never be satisfied, and every round costs a search and a call. Anthropic recommends stopping conditions, such as a maximum number of iterations, and warns that the autonomy of agents brings higher costs and errors that pile up.

An everyday example

You're looking for your keys: if they don't turn up after checking three places, you stop and say so, instead of checking the same drawer all afternoon.

The code

Before, the loop searches until the model says it's enough. With the parking question that never happens: after 1,000 searches the loop is still going.

/// <summary>
/// BEFORE the limit: searches until the model says the passages are enough. When the manuals do not
/// have the answer, that never happens and the loop does not end. onSearch lets a test see each search
/// (and stop the loop by throwing); this class itself has no exit for that case.
/// </summary>
public sealed class UnboundedAgenticRag(ManualIndex index, int top = 2)
{
    public RagResult Ask(string question, Action<int>? onSearch = null)
    {
        var model = new SimulatedModel();
        var query = model.Plan(question);
        var passages = new List<Document>();
        var searches = 0;
        while (true)
        {
            searches++;
            onSearch?.Invoke(searches);
            foreach (var d in index.Search(query, top))
                if (!passages.Contains(d)) passages.Add(d);

            var verdict = model.Check(question, passages);
            if (verdict is Verdict.Enough) break;
            if (verdict is Verdict.SearchAgain again) query = again.Query;
            // Not in the manuals: search again with the same query, "maybe this time".
        }
        var (answer, sources) = model.Answer(question, passages);
        return new RagResult(answer, sources, searches, model.Calls);
    }
}

After, the agentic version you already saw stops for four reasons: it answered, it's not in the manuals, it hit the limit, or the model asked for a search it had already made. Unless it answered, it says so in the answer. The badge question needs four searches; with a limit of 3, it stops and warns:

public void The_search_limit_stops_a_long_chain_and_says_the_answer_may_be_incomplete()
{
    var r = new AgenticRag(Index, maxSearches: 3).Ask(FourSearches);

    Assert.True(r.StoppedAtLimit);
    Assert.Equal(3, r.Searches);
    Assert.DoesNotContain("4730", r.Answer);
    Assert.EndsWith("(Stopped at the search limit of 3; this answer may be incomplete.)", r.Answer);
}

With a limit of 4 it reaches extension 4730. If two manuals point to each other, the agentic version stops on the repeated search, after 2, and warns as well. The limit trades a complete answer for a bounded cost, and 3 is a choice made for the example, not a value any source recommends.

The figures always come out the same because the example's model is simulated. With a real model, which can rephrase the search badly or go round in circles without making progress, the limit and the check matter even more.

Make the answer say when the search was cut short: an incomplete answer that says so is worth more than one that looks complete.

What guards it

In production, the signal is the stop reason, StopReason, which travels with every agentic and adaptive result, and the warning at the end of the answer. Normal RAG doesn't check, so its stop reason is always that it answered. What it doesn't guard: which limit suits you. That depends on how many documents your questions chain, and only your questions can tell you.

Anthropic writes: "The task often terminates upon completion, but it's also common to include stopping conditions (such as a maximum number of iterations) to maintain control". And: "The autonomous nature of agents means higher costs, and the potential for compounding errors."

When to use each one

SituationApproachWhy
Questions answered by one pageNormal RAGOne search and one call
Answers spread across several pages, or a mixNormal with one check (adaptive)Steps up only when something is missing, with one call fewer than agentic in this example
Questions where planning the first search changes what is foundAgentic RAGPlans before searching; this example has no such case
Any agentWith a search capStops and warns that the answer may be incomplete

Run with the .NET SDK 10.0.401, with no models, no embeddings and no API: the model is a simulation with fixed rules and the index lives in memory.

Conclusion

Where each piece of a RAG project goes is covered in maintainable RAG project structure. To try it with your own questions, clone the repository and run dotnet test; the demo, dotnet run --project tools/RagDemo, prints the figures in this post.

Before turning your assistant into an agent, look at your last hundred questions: if almost all of them are answered by one page, an agent only charges you more to get to the same place.

References

Subscribe

Get the latest posts delivered right to your inbox.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Comments

No comments yet. Be the first to share your thoughts!

Subscribed!

Registered! A confirmation link has been sent to your email address. If you don't see it, please check your spam folder.

Error

An error occurred. Please try again.

Full code