Agent infrastructure

Agents in production

RAG vs tool calling: which one your agent actually needs

RAG vs tool calling for AI agents: how each pattern works, where each one fits, and why most production agents need tool calling before retrieval.

7 minute read
Decorative imagery showcasing Pontil's brand

Retrieval-augmented generation and tool calling get lumped together in agent architecture discussions. They shouldn't be. They solve different problems, they fail in different ways, and picking the wrong one is one of the more expensive mistakes an agent project can make early on.

This comparison is for engineering leads and heads of AI deciding how their agent reaches information and takes action. The short version: RAG is how an agent reads. Tool calling is how an agent does. Most production agents need both, but the order you build them in — and which one you lean on for a given capability — decides whether the project ships or stalls.

How RAG works

Retrieval-augmented generation is a pattern for grounding a model's output in a specific corpus. At query time, the system takes the user's input, converts it to an embedding, searches a vector store for semantically similar chunks, and passes those chunks into the model's context window alongside the original prompt. The model then generates a response conditioned on that retrieved content.

The pipeline has moving parts. You need an ingestion step that chunks source documents and embeds them. You need a vector database — Pinecone, Weaviate, pgvector, or similar. You need a retrieval step that handles the query embedding, similarity search, and often re-ranking. And you need prompt assembly logic that decides how retrieved chunks are formatted and truncated before hitting the model.

RAG shines when the answer already exists somewhere in text and the agent needs to find and summarise it. Documentation lookup, policy questions, historical ticket search, knowledge-base Q&A — all classic RAG territory. It's a read pattern. Nothing changes in the underlying system as a result of the retrieval.

How tool calling works

Tool calling is the mechanism by which a model requests that the runtime execute a defined function. The model doesn't run the function itself — it emits a structured call (name plus arguments), the runtime executes it against the real system, and the result is fed back into the model's context. Modern foundation models from Anthropic, OpenAI, and Google all support this natively through their APIs.

Each tool is a contract: a name, a schema for arguments, and an implementation that does something. That something can be anything a program can do. Query a database. Send an email. Update a CRM record. Cancel a subscription. Kick off a workflow. Tool calling is how an agent stops being a chat interface and starts being a system that affects the world.

The reliability question with tool calling is different from RAG. RAG can be wrong (retrieve the wrong chunk, hallucinate around it). Tool calling can be destructive — wrong arguments to a real API don't just produce a bad answer, they produce a bad outcome. Which is why the runtime around tool calls matters as much as the tool definitions themselves. If you want to go deeper on where those two failure modes diverge, our post on tool calling vs function calling covers the production reality.

The comparison that actually matters

RAG
Tool calling

Primary purpose

Read

Act

State change

None — read-only over a corpus

Yes — mutates real systems

Data freshness

As fresh as the last ingestion job

Live, at the moment of the call

Failure mode

Wrong or missing retrieval, hallucination around gaps

Wrong arguments, unintended side effects, retries duplicating writes

Auth model

Usually service account against the vector store

Should execute as the authenticated user, with real permissions

Latency profile

Roughly 100–500ms end-to-end, including query embedding, similarity search, and any re-ranking (raw vector search itself is often <20ms)

Highly variable — depends on the underlying API

Cost driver

Embedding + storage + retrieval calls

Per-API-call cost of the underlying tools

What breaks silently

Stale index, chunking that splits semantic units

Upstream API drift, auth token expiry, rate limits


The row that matters most is the one about state change. Read-only patterns and mutating patterns should not share failure modes, retry logic, or observability. Conflating them is how agent projects end up with tool calls being retried three times because the runtime treated them like a search query.

When to choose RAG

Reach for RAG when the capability is fundamentally about finding and synthesising information from a body of text.

  • Documentation and knowledge-base Q&A. The answer is written down somewhere. The agent needs to find it and phrase it well.
  • Policy, contract, or compliance lookup. Long documents, specific clauses, precise citations.
  • Historical context. Past support tickets, previous meeting notes, prior research. Anything where the corpus is stable-ish and read-heavy.
  • Content grounding. When you need the model's response to stay tied to a specific source rather than its training data.

RAG is also the right choice when you don't control the underlying system and can't get proper API access. Scraping documentation into a vector store isn't ideal, but it's better than fabricating.

What RAG cannot do: take action. If the user asks "what's my current subscription status?" and you've indexed the billing docs, RAG will tell them what subscriptions exist as a concept. It won't tell them theirs. For that, you need tool calling.

When to choose tool calling

Reach for tool calling when the capability is about interacting with a live system — either to read current state or to change it.

  • Anything user-specific. "Show me my open tickets", "cancel my trial", "add this contact to my pipeline". The answer is per-user and lives behind auth.
  • Anything that mutates state. Creating, updating, deleting, triggering. If the outcome of the call is a change in the world, it's a tool call.
  • Live data. Prices, inventory, account balances, availability. Anything where a stale answer is worse than no answer.
  • Multi-step workflows. Agentic sequences where each step depends on the real result of the previous one, not on retrieved documentation about what the result should look like.

The hard part of tool calling in production isn't the model side — foundation models handle the schema and the call emission well now. The hard part is the runtime: authenticating as the right user, honouring their permissions, retrying safely, handling rate limits, catching upstream drift when the underlying API changes. Our guides on API idempotency for AI agents and AI agent guardrails both dig into that runtime layer, which is where most production incidents actually happen.

Agentic RAG: the pattern that blurs the line

The interesting middle ground is agentic RAG. Instead of a fixed retrieve-then-generate pipeline, the agent decides when to retrieve, what to retrieve, and whether to retrieve at all — usually by exposing retrieval itself as a tool.

In this pattern, search_docs is just another tool in the agent's toolbox, alongside create_ticket or update_contact. The model decides based on the user's request which combination of tools to invoke and in what order. That's more flexible than a hard-coded RAG pipeline, and it lets the same agent handle read-heavy questions and mutating actions without switching architectures.

Agentic RAG doesn't remove the read/write distinction — it just moves the decision into the model. You still need to design the retrieval tool differently from the mutating tools. Different auth model, different retry semantics, different observability. But the interface the agent sees is uniform, and that uniformity is what makes complex flows tractable.

This is also where the "RAG vs agents" framing gets clearer. Agents use retrieval. Retrieval isn't a competing architecture; it's one capability among many.

How Pontil fits

The reason the read/write distinction matters is that most established SaaS companies building agents run into the write side and stall. Their APIs cover a small fraction of what the product can do, so their agents can search documentation about a feature but can't invoke it. RAG covers the read gap by pointing at text. It doesn't cover the action gap.

Pontil is a Tools-as-a-Service platform that generates and runs the tools an agent needs to reach the parts of a product that its existing APIs don't expose. Tool calling only works if there are tools to call, and for most SaaS products those tools don't exist yet. We generate them from the codebase, run them through a runtime that executes as the authenticated user, and maintain them as the product changes. If your agent project is currently sitting at "the retrieval works but the agent can't actually do anything", that's the gap we close. A product walkthrough is the fastest way to see what that looks like on a real codebase.

What we'd choose

Start with the read/write question, not the technology question. For every capability your agent needs, ask: does answering this require reading a corpus, or does it require touching a live system?

If it's read-only over stable text, RAG. If it's user-specific, live, or mutating, tool calling. If it's both — and most production agents are — build the tool calling layer first, expose retrieval as one of the tools, and let the model orchestrate. That order matters. Retrieval on its own produces a chatbot that knows things. Tool calling on its own produces an agent that can do things. The combination, in that order, produces an agent that can actually be trusted with real work.

The teams that get stuck are usually the ones that built impressive RAG demos and then discovered that their agent can't reach the vast majority of their product that isn't documented as text. Answer the read/write question early and the rest of the architecture follows.

Join our weekly newsletter

Stay up to date on the ever changing agentic landscape.

POSTS

Related content

Agent infrastructure

Agents in production

Tool calling vs function calling: the same mechanism, two production realities

8 minute read

Agent infrastructure

Platform integration

Orchestrator vs tools layer: where agent work actually happens

7 min read

Agent infrastructure

Agents in production

Agentic workflows: what they are, how they break, and what makes them production-grade

8 minute read