Multi-Agent RAG: Architecture Design and Engineering Practice

    Multi-agent RAG splits complex knowledge tasks across planning, retrieval, evidence organization, answer generation, and verification, then coordinates those roles through a bounded workflow. This article explains when that design is worth the cost, how to set system boundaries, build a reliable knowledge base and retrieval layer, assign agent responsibilities, control collaboration with a state machine, enforce security, evaluate results, and roll the system out in stages.

    1. Define the Problem: Why Multi-Agent RAG

    A large language model’s knowledge mainly comes from training, so it does not naturally know an organization’s latest policies, internal documents, project records, or business data. A fluent answer is not necessarily accurate, and it is not necessarily consistent with the current user’s access rights.

    Retrieval-augmented generation, or RAG, usually supplements the model’s context by retrieving relevant material and then generating an answer from that material. It fits cases where knowledge keeps changing, answers need source citations, or data cannot be used directly for model training. RAG does not automatically remove hallucinations. Missed retrieval, outdated documents, mixed context, and incorrect inference during generation can all affect the final result.

    Basic RAG usually follows a fixed path:

    User question → retrieve from the knowledge base → organize context → generate an answer.

    That path works when the question is clear, the evidence is concentrated, and the task is relatively simple. One retrieval pass is often not enough when a question spans multiple departments, multiple knowledge sources, or several reasoning steps. For example:

    Does this type of purchase require approval? Which steps are involved? What should happen if the budget exceeds the original plan?

    Answering that question may require consulting purchasing policy, authorization rules, and budget-management rules, then judging whether different clauses apply to the same business situation.

    The value of multi-agent RAG is that it breaks a complex task into clearly scoped stages. Different roles handle planning, retrieval, evidence organization, answer generation, and verification, and a shared orchestration mechanism produces the result.

    Multi-agent design is not better than a single agent by default. Every added role can increase call cost, latency, and state-management overhead. The right order is to build a reliable basic RAG system first, then add collaboration only for tasks that are genuinely complex.

    2. Work Backward from Business Needs to System Boundaries

    Before writing retrieval code, define what the system should answer, what it should not answer, and how trustworthy an answer needs to be.

    2.1 Question types and output requirements

    Enterprise knowledge questions can be divided into three types:

    • Factual lookup: Find a specific rule, term, or explicit statement in a document.
    • Synthesis: Combine multiple sources to explain conditions, processes, differences, or effects.
    • Action guidance: Use the user’s context to suggest a next step.

    Different question types should follow different execution paths. Factual lookup usually does not need complex planning. Synthesis benefits from question decomposition and multi-round retrieval. Action guidance also needs clear conditions of applicability, uncertainty, and business boundaries.

    For high-risk business matters, the system should act as an information aid. It should not turn an unauthorized suggestion directly into a business operation.

    2.2 Acceptance criteria

    “The answer looks good” is not an acceptance standard. At a minimum, define whether:

    • key evidence can be retrieved;
    • conclusions in the answer have corresponding support;
    • citations are real, accessible, and consistent with the conclusions;
    • the system can explain its limits when evidence is missing;
    • users with different permissions can access only what they are allowed to see;
    • latency and resource use meet business requirements.

    These targets drive later architecture choices and help avoid aimless prompt tuning after launch.

    3. Build the Knowledge Base First: Quality Before Agent Collaboration

    Multiple agents cannot compensate for a poor knowledge base. If the retrieval layer cannot find the right material over time, adding more model roles usually makes the problem worse.

    3.1 Document parsing and structure

    Ingestion should preserve headings, sections, tables, lists, footnotes, and relationships to attachments as far as possible. In policy documents, scope, exceptions, and effective-date statements are often more important than a single conclusion in the body.

    For tables, keep the correspondence between rows and columns. For scanned material, watch for recognition errors and sample them manually when necessary. A wrong amount, date, or negation can change the meaning of an answer.

    3.2 Split along semantic boundaries

    Splitting is not simply cutting text at a fixed character count. A better approach is to follow section, paragraph, and business-rule boundaries first, then control chunk length against the model’s context limit.

    Each chunk should contain a complete unit of meaning where possible. For example, “conditions of applicability” and “handling requirements” should not be fully separated. Adjacent chunks can overlap moderately, but too much overlap increases duplicate retrieval and wastes context.

    Recommended metadata for each chunk:

    1. Document ID
    2. Chunk ID
    3. Document title
    4. Section path
    5. Source location
    6. Version information
    7. Effective date
    8. Expiration date
    9. Permission scope
    10. Content summary

    Permission and version fields are not only for display. They should also participate in retrieval filtering and evidence selection.

    3.3 Updates and expiration

    A knowledge base is not finished after a one-time import. When a document changes, identify the change, re-chunk it, and update the index. When a document is withdrawn, update the index, cache, and citation entry points together.

    When several versions of the same policy exist, decide from the user’s question whether the current effective version or a historical version should be used. An older version should not become the current basis only because it has a higher semantic similarity to the question.

    4. Retrieval Design: Get Reliable Evidence into Context

    The retrieval layer decides what the system “sees.” If key evidence never enters the candidate set, later generation and verification have no foundation.

    4.1 Combine retrieval methods

    Keyword retrieval fits identifiers, specialized terms, and exact conditions. Vector retrieval fits questions that are worded differently but mean something similar. For an enterprise knowledge base, combining both is usually more robust.

    A typical flow is:

    Permission and time-range filtering → multi-path candidate recall → deduplication → reranking → evidence selection.

    Reranking further judges how relevant a candidate chunk is to the question. Evidence selection should also consider coverage, not only relevance scores. When answering a complete process, several complementary sections are usually more valuable than several highly repetitive passages.

    4.2 Query rewriting must not change the original meaning

    Query rewriting can add synonymous phrasing, expand abbreviations, or split a compound question. It must not invent conditions the user did not provide.

    If a user asks how to claim expenses for a business trip away from their usual location, the system must not assume the destination, the person’s level, or the expense standard. If those facts would change the conclusion, ask for them first, or distinguish the applicable cases in the answer.

    4.3 Allow the system to stop when evidence is insufficient

    No retrieval result does not necessarily mean the knowledge base has no answer. The query may be poorly expressed, the index may be incomplete, or permissions may block access.

    The system can run controlled follow-up retrieval, but it must cap the number of attempts and the resources used. After the limit is reached, state what has been confirmed and what is still missing. Do not let the model keep guessing.

    5. Agent Responsibilities Must Match Real Needs

    A practical role split can look like the following, but each role does not need its own model. Simple judgments, format checks, and permission checks are better handled by deterministic programs.

    5.1 Planning agent

    It classifies the question, identifies missing conditions, splits the question into sub-questions, and defines a retrieval goal for each sub-question.

    The plan should stay structured, for example:

    1. Sub-question 1: Confirm the policy’s scope
    2. Sub-question 2: Find the standard approval process
    3. Sub-question 3: Find exception rules for budget changes
    4. Missing information: When the business event occurred
    5. Stop condition: Valid evidence covers each sub-question, or the retrieval budget is reached

    For simple questions, planning should be allowed to skip ahead so that not every request enters the complex path.

    5.2 Retrieval agent

    It chooses the knowledge scope for a sub-question, builds the query, and calls retrieval. Its core output is an evidence set, not a final answer.

    Each piece of evidence should be linked to the original document, chunk location, and conditions of applicability so later checks and tracing are possible.

    5.3 Evidence-organization agent

    It merges duplicate information, distinguishes valid versions, identifies conflicts, and builds a mapping from sub-questions to evidence.

    It should keep important limiting conditions and must not drop exception clauses just to make a summary shorter. When sources conflict, it should not simply prefer the longer or more confident text.

    5.4 Answer agent

    It generates an answer from the organized evidence and clearly separates:

    • facts stated directly in documents;
    • inferences drawn from multiple facts;
    • matters that still lack sufficient evidence.

    Key conclusions should carry citation identifiers. A citation should locate an actual chunk, not only a document name.

    5.5 Verification agent

    It checks whether the answer goes beyond the evidence, whether citations support the corresponding conclusions, whether conditions of applicability were omitted, and whether the answer contradicts itself.

    A verification agent is not an infallible judge. Models can share similar biases, so programmatic checks are still required, such as citation-identifier existence, permission checks, and date-validity checks.

    6. Organize Collaboration with a State Machine, Not Free Chat

    A controllable multi-agent system is closer to a workflow with conditional branches than to endless discussion among roles.

    Maintain a shared task state:

    1. Original question
    2. Confirmed user conditions
    3. Sub-question list
    4. Retrieval records
    5. Candidate evidence
    6. Adopted evidence
    7. Evidence conflicts
    8. Answer draft
    9. Verification issues
    10. Execution budget
    11. End reason

    A typical state transition is:

    1. Receive question
    2. → Decide whether more conditions are needed
    3. → Plan or retrieve directly
    4. → Organize evidence
    5. → Judge whether evidence is sufficient
    6. → Generate an answer
    7. → Verify the answer
    8. → Return the result or run a limited repair

    Roles should pass information through structured fields rather than only free text. Structured handoff reduces the chance of losing key information and makes logging and testing easier.

    Set a maximum number of retrieval rounds, a maximum number of repairs, a total execution time limit, and a context budget. When a boundary is reached, return a limited conclusion or hand the case to a person. Do not retry without limit.

    7. Example of the Core Execution Logic

    The pseudocode below illustrates the architecture. Function names are custom abstractions. They do not represent the interface of any existing product and cannot be run as written.

    1. function answer_question(question, identity, limits):
    2. context = create_task_context(question, identity)
    3. decision = assess_question(question)
    4. if decision.requires_clarification:
    5. return request_clarification(decision.missing_fields)
    6. if decision.is_simple:
    7. tasks = [create_direct_search_task(question)]
    8. else:
    9. tasks = plan_subquestions(question)
    10. evidence_pool = []
    11. for task in tasks:
    12. if budget_exhausted(context, limits):
    13. break
    14. candidates = retrieve(
    15. query = task.query,
    16. access_scope = identity.access_scope,
    17. time_scope = task.time_scope
    18. )
    19. candidates = remove_duplicates(candidates)
    20. ranked = rerank(task, candidates)
    21. evidence_pool.extend(select_evidence(task, ranked))
    22. record_search_trace(context, task, ranked)
    23. evidence = organize_and_check_versions(evidence_pool)
    24. if not evidence_is_sufficient(tasks, evidence):
    25. return build_partial_response(
    26. supported_facts = evidence,
    27. missing_information = find_evidence_gaps(tasks, evidence)
    28. )
    29. draft = generate_grounded_answer(question, evidence)
    30. report = verify_answer(draft, evidence, identity)
    31. if report.passed:
    32. return attach_traceable_citations(draft, evidence)
    33. if repair_allowed(context, limits):
    34. repaired = repair_answer(draft, report, evidence)
    35. final_report = verify_answer(repaired, evidence, identity)
    36. if final_report.passed:
    37. return attach_traceable_citations(repaired, evidence)
    38. return build_safe_fallback(report, evidence)

    This logic reflects three principles: permission constraints run through evidence collection, evidence sufficiency is judged before generation, and a repair must be verified again.

    A real implementation also has to handle retrieval timeouts, invalid model output formats, unavailable indexes, and partial task failures. Exception handling should not be only “call again.” Choose retry, degradation, or termination according to the failure type.

    8. Security: Treat Documents as Data, Not Instructions

    Retrieved documents may contain misleading content, including text that tells the model to ignore rules, leak information, or call external capabilities. The system must clearly separate trusted control instructions from untrusted source content.

    Knowledge-base content may be used only as the basis for an answer. It must not override system rules. Agent capabilities should follow least privilege. A question-answering role should not have the ability to modify business data by default.

    Access control cannot rely on prompts. Enforce access checks during recall, evidence reading, and answer return so the model does not see sensitive material and then get told not to mention it.

    Caches also need permission awareness. Reusing another user’s answer can leak information across permission boundaries. Cache design should include the necessary constraints on permissions, knowledge versions, and task conditions.

    When the system is extended to perform actions, separate “generate a suggestion” from “submit an operation.” Critical actions should require explicit confirmation, parameter validation, and an audit record.

    9. Evaluation and Observability: Prove the Complex Architecture Works

    Whether a multi-agent design is worth using should be shown by tests, not by the number of roles.

    9.1 Layered evaluation

    At the retrieval layer, observe recall of key evidence, relevance, version correctness, and permission-filtering results.

    At the answer layer, evaluate conclusion correctness, evidence support, citation accuracy, completeness, and behavior when there is no answer.

    At the system layer, track end-to-end latency, call count, resource use, failure rate, and task completion rate.

    The evaluation set should cover ordinary questions, cross-document questions, ambiguous questions, conflicting documents, historical versions, no-answer cases, and unauthorized requests. Testing only common simple questions cannot show the real value of a multi-agent architecture.

    9.2 Traceable records

    Record the plan, retrieval queries, adopted evidence, state transitions, verification issues, and stop reason for each request. Logs should be redacted as needed, with access controls and a retention period.

    These records show whether an error came from document processing, retrieval, evidence organization, or answer generation, instead of attributing everything vaguely to weak model capability.

    9.3 Compare with the baseline

    Compare basic RAG and multi-agent RAG on the same test set. If quality on complex questions does not improve clearly while latency and cost keep rising, reduce roles, simplify the flow, or change how tasks are split.

    Architectural complexity has engineering value only when it produces a verifiable business benefit.

    In the first stage, close the basic RAG loop: document ingestion, permission filtering, retrieval, citations, and no-answer handling. The focus is data quality and the evaluation set.

    In the second stage, add planning for complex questions and evidence-coverage checks so cross-document tasks can be decomposed explicitly, and cap follow-up retrieval.

    In the third stage, add answer verification and limited repair, and complete version management, failure degradation, auditing, and observability.

    In the fourth stage, tune execution paths from real business feedback. Simple questions take the short path, complex questions take the collaborative path, and high-risk questions keep a human review entry point.

    The point of multi-agent RAG is not to involve more models in answering. It is to turn a complex knowledge task into an engineering process with boundaries, evidence, state, and verification. The system can move from a demo to a maintainable application only when knowledge governance, retrieval quality, collaboration, and security controls all hold together.