Architecture decision
RAG vs AI Agents: Choose the Simpler Architecture First
Use RAG when the job is to answer from a controlled body of evidence. Use a deterministic workflow when the steps are known. Add an agent only when the system must choose actions, inspect results, and revise a plan under explicit permissions and stop conditions.
How this guide was produced
Architecture synthesis from official RAG, agent-runtime, and AI risk-management documentation. No vendor benchmark is claimed.
AI assisted with research organization and editing. It is not treated as a source. Product capabilities and prices can change; verify the linked primary sources before making a purchase or production decision.
The distinction that matters
RAG changes what evidence is available to a model. An agent changes how the system decides what to do next. They solve different problems and can be combined, but combining them should be an outcome of requirements—not the starting assumption.
A retrieval system typically accepts a question, finds relevant chunks from an indexed corpus, and gives those chunks to a model for a grounded answer. An agent runtime typically manages a loop in which a model chooses a tool or action, receives the result, updates state, and continues until completion or interruption.
Decision matrix
| Job | Start with | Main controls |
|---|---|---|
| Answer from a controlled knowledge base | RAG | Retrieval quality, freshness, citations, answer evaluation |
| Extract or classify with fixed steps | Direct model call or workflow | Schema validation, deterministic routing, retries |
| Gather evidence from several known systems | Workflow with retrieval/tools | Access policy, source logging, step-level tests |
| Choose tools and adapt a plan from intermediate results | Bounded agent | Budgets, approvals, traces, stop conditions |
| Perform irreversible external actions | Workflow or agent with mandatory approval | Identity, authorization, idempotency, audit trail |
Choose RAG when evidence is the product
RAG is appropriate for policy assistants, product documentation, internal knowledge search, research support, and customer support answers when users need a response grounded in a defined corpus. The central quality questions are whether the right documents were indexed, whether retrieval found the right passages, whether sources are current, and whether the answer remains supported by those passages.
RAG does not automatically prevent hallucination. Evaluate retrieval and generation separately: document coverage, chunking, recall, ranking, citation correctness, answer faithfulness, and refusal when evidence is insufficient.
Choose a workflow when the sequence is known
A workflow is often more reliable than an agent for invoice extraction, support routing, document review, content checks, or onboarding processes. A model can classify or generate inside a step while the application owns transitions, retries, approvals, and side effects.
This matters because deterministic control makes failures easier to reproduce. If step three fails, the system can preserve state and retry that step without asking a model to reconstruct the entire plan.
Choose an agent when adaptation is necessary
An agent becomes useful when the system cannot know the full sequence in advance: research across changing sources, investigation based on intermediate evidence, coding across a repository, or support tasks that require selecting among several diagnostic tools. Even then, autonomy should be bounded by tool allowlists, permissions, time, spend, and human approval.
Do not use multiple agents merely to assign fictional job titles. Add another agent only when it has a distinct tool boundary, context boundary, evaluation target, or delegation role that cannot be represented clearly in one controlled workflow.
Hybrid pattern: retrieval inside a controlled agent
- The application authenticates the user and establishes document and tool permissions.
- Retrieval returns evidence the user is allowed to see, with source identifiers and freshness metadata.
- The model proposes an answer or next action using that evidence.
- Policy code validates the proposed tool, arguments, target, and approval requirement.
- The system executes only the authorized action and records the result.
- The loop stops on success, budget exhaustion, uncertainty, or a mandatory human interruption.
This pattern keeps retrieval permissions and action permissions separate. Access to a document should not imply permission to send, edit, delete, purchase, or execute.
Evaluation plan
- RAG: measure source coverage, retrieval recall, citation correctness, faithfulness, and unsupported-answer refusal.
- Workflow: measure step completion, schema validity, exception routing, idempotency, and manual correction rate.
- Agent: measure accepted task completion, tool-selection errors, unnecessary steps, policy violations, intervention rate, and cost per accepted result.
- Hybrid: add permission leakage, stale-evidence handling, action attribution, and recovery after a failed tool call.
Worked boundary example
Consider an internal policy assistant that can also open a support case. Retrieval should answer policy questions from approved documents and return citations. A deterministic application rule decides whether the request is eligible for escalation. Only then may a bounded agent gather missing facts from allowed systems. Creating the case remains a typed tool action with the authenticated employee, target queue, summary, and attachments validated by application policy.
This decomposition makes evaluation specific. Retrieval tests whether the answer is supported. The workflow tests eligibility and required fields. The agent tests whether it gathers facts without leaving scope. The tool gateway tests authorization and duplicate prevention. Combining all four into one unconstrained prompt would make a failure harder to locate and could let document text influence an external action.
Worked architecture boundaries
Internal policy questions: begin with retrieval over approved, versioned policy documents. Require citations and abstain when sources conflict or lack the answer. A deterministic workflow can collect missing user context or open a ticket. An agent is unnecessary unless the system must select among changing investigative actions; even then, policy approval and final decisions remain outside retrieved instructions.
Customer support: retrieval can draft an evidence-bound answer, while a workflow validates account state and routes the case. Use an agent only for bounded diagnosis that genuinely depends on previous tool results. Refunds, account changes, or external messages should use typed tools, authorization, and approval rather than free-form agent authority.
Incident investigation: an agent may be justified when it must choose the next read-only query from observed logs and metrics. Keep remediation separate. The agent produces an evidence packet and proposed action; a deterministic or human-approved workflow performs the consequential change with an idempotent transaction and post-action validation.
Document production: retrieval supplies current sources, a workflow enforces required sections and review, and direct model calls draft bounded sections. An agent may gather missing evidence, but publication remains a separate editorial action. This design makes unsupported claims and failed acquisition visible before content reaches users.
Test the lowest sufficient level
Create the same 30–50 representative cases for each plausible architecture. Measure accepted outcomes, evidence support, intervention, critical errors, latency, total cost, and failure recovery. For retrieval, inspect relevant passages and groundedness. For workflows, test every branch and duplicate event. For agents, inspect authority, trajectories, stop behavior, and interrupted state.
Promote to a more autonomous level only when the simpler level fails a named requirement by a meaningful margin. Record the examples. If retrieval plus a workflow meets the acceptance bar, an agent’s additional flexibility is operational burden without demonstrated value. If an agent materially improves difficult cases, route only those cases until broader evidence exists.
Avoid architecture drift
Systems often become agents accidentally: a direct call gains memory, retrieval, retries, dynamic tools, and permission to act without anyone revisiting the design. Maintain an authority inventory and trigger review when adding a tool, persistent state, new data class, external destination, longer loop, or automatic side effect. Architecture is defined by real capability, not the label in a diagram.
Keep state typed and purpose-specific. Conversation history is not a reliable policy store, approval record, or transaction ledger. Store facts with provenance and retention, enforce permissions in application code, and link actions to external result validation.
Review cost and failure surface together. Retrieval adds ingestion and freshness work; workflows add branch and state maintenance; agents add variable trajectories and tool risk. Select the smallest stack whose measured benefit exceeds these ongoing obligations, and preserve a manual or deterministic fallback for uncertain cases.
State the stop condition at every level. Retrieval stops when adequate authorized evidence is assembled or reports that it is missing. A workflow stops at a defined terminal or exception state. An agent stops at an accepted result, policy boundary, budget, repeated failure, or escalation. Open-ended continuation is not an architecture requirement.
Limitations
Architecture names do not create clean boundaries in every product; many platforms combine retrieval, workflow, and agent capabilities. This guide is a conceptual decision model, not a compliance framework or performance benchmark. High-impact applications need domain-specific controls, testing, and legal review.
Next steps
Score the process with the automation readiness checklist. If an agent is justified, use the framework selection checklist. Before connecting tools, apply the security controls and set a budget with the cost model.
Primary sources
Sources were checked on . Follow the links for current product details.
- Azure AI Search RAG overview
Official overview of retrieval, grounding, citations, and RAG architecture.
- Anthropic: Building effective agents
Explains workflows, agents, and the value of simple composable patterns.
- OpenAI Agents SDK documentation
Documents tool loops, guardrails, sessions, handoffs, tracing, and human review.
- NIST AI Risk Management Framework
Voluntary framework for incorporating trustworthiness into AI design, use, and evaluation.
- LangGraph overview
Official description of durable, stateful agent and workflow orchestration.