Skip to content
Agent Integration8 min read·

Case study: Rubi.AI's three-agent clinical intake pipeline

Rubi.AI runs patient intake as three agents: one that extracts and scores what the patient has said, one that retrieves clinical literature, and one that answers in plain language with citations. This is how the pipeline is put together, why it asks a followup below an 80% context score, and why it will not diagnose.

MultiagentRAGCase StudyHealthcare AICitationsGuardrails

Search for a multiagent RAG case study and most of what I find is one of two things: framework tutorials that wire three agents together on a toy dataset, or vendor pages with an architecture diagram and a headline percentage. Both skip the decisions that matter in a real product. When does the system stop asking and start answering? What does it refuse to do? How does a reader check that the answer came from somewhere? This post walks through those decisions in Rubi.AI, a live AI medical assistant from my own portfolio, using only what the system actually does.

I am not going to quote accuracy figures or user numbers, because none are published for this project and an invented one would undermine the whole point of the design, which is that every claim should be traceable.

The problem: plain language in, traceable answers out

Patients describe symptoms the way people talk: out of order, missing the detail a clinician would ask for first, mixing what they feel with what they have read. A clinical answer has to work the other way round. It has to be traceable back to literature, and it can only be as good as the description it was based on.

So the brief for Rubi.AI had two requirements that pull against a normal chatbot. It had to gather enough context before answering, and it had to show its working while it did. A single prompt over a vector database does neither well. It answers whatever it is asked, immediately, and the reasoning is invisible.

The pipeline: three agents, one job each

Rubi.AI runs intake as a three-agent pipeline. Each agent has one responsibility and hands a defined output to the next. Each stage is also visible in the interface as it runs, so the patient sees intake, retrieval and summarisation happen rather than waiting on a spinner.

One patient message through Rubi.AI
  1. Patient describes the problem

    Typed, or spoken through speech-to-text

  2. Intake agent (DIVA) extracts clinical entities

    Turns free text into structured clinical detail

  3. Score context understanding

    How completely the description has been understood, shown on a live meter

    ↳ Below 80%: ask a followup question and wait for the reply

  4. Retrieval agent searches clinical literature

    Vector search across the configured sources

  5. Summarization agent writes the answer

    Plain language, with citations to the retrieved literature

  6. Answer shown with sources

    General information only, never a diagnosis or a medication recommendation

↺ The followup loop repeats until the context score reaches 80%

Retrieval never runs on a description the intake agent has scored below the threshold.

AgentIts one jobWhat it hands onWhy it is separate
Intake (DIVA)Extract clinical entities from the patient's own words and score how complete they areStructured clinical detail, or a followup questionUnderstanding the question is a different task from answering it, and it needs its own stop condition
RetrievalSearch a vector database of clinical literatureThe passages most relevant to the extracted detailRetrieval quality can be measured on its own, without a model writing prose on top
SummarizationTurn retrieved passages into a patient-friendly answerA plain-language answer with citationsTone and readability can change without touching what was retrieved

The split is not there because multiagent is fashionable. It is there because each stage fails in a different way, and a single prompt hides which one failed. If an answer is wrong, I want to know whether the patient was misunderstood, the wrong literature was found, or the right literature was summarised badly. Three agents with three outputs make that question answerable.

It also makes the pipeline operable. Rubi.AI has an admin console that can enable or disable agents in the pipeline, so a stage can be switched off and the behaviour of the rest observed, which is much harder when everything lives in one prompt.

The 80% gate: when to ask instead of answer

The intake agent does not just extract. It scores how much it has understood so far, and that score is shown to the patient on a live context-understanding meter for each session. Below 80%, the agent asks a followup instead of proceeding to retrieval.

The reasoning is simple. Retrieval is only as good as its query. A vague description produces a vague search, and a vague search produces passages that are loosely related to everything and specifically relevant to nothing. The summarization agent will then write something fluent from them anyway, because that is what language models do. The cheapest place to stop that chain is at the very start, before any literature is fetched.

Why a threshold and not a judgment call left to the model? Because a number can be tuned, logged and tested. A prompt that says "ask more questions if you need to" will ask too many for some patients and too few for others, and there is no single dial to adjust. A score with a fixed gate turns "has it understood enough?" into something you can put in an eval suite and check on every change. The 80% figure itself is a product threshold, a trade-off between asking patients too many questions and answering on too little. It is not a clinical constant, and it is the kind of value you expect to revisit.

The meter also changes how the followup feels. Without it, a second question reads as the assistant being slow or difficult. With it, the patient can see why it is asking: the bar is not full yet. Showing the working turns the followup from friction into part of the conversation.

Citations: making a medical answer checkable

The summarization agent answers in plain language with citations back to the clinical literature that retrieval found. In most RAG products citations are a nice-to-have. In a health assistant I would treat them as the product.

  • They let the reader check. A patient, a carer or a clinician can follow a sentence back to its source instead of trusting a confident paragraph.
  • They constrain the writer. An agent that has to attach a source to what it says has less room to fill gaps with plausible text that came from nowhere.
  • They make the system testable. You can check mechanically that every cited passage was in the retrieved set, and then judge whether it supports the sentence it is attached to. I covered that ladder of checks in the evals post.
  • They separate failures. A wrong answer with a correct citation is a summarisation problem. A wrong answer with a weak citation is a retrieval problem. Without citations you cannot tell them apart.

Why it refuses to diagnose

Rubi.AI is scoped to general information. It does not diagnose, it does not recommend medication, and it says so in the interface. This is the decision I would defend hardest, because it is the one most tempting to quietly relax once a demo goes well.

Rubi.AI doesRubi.AI does not
Help a patient describe their situation completely, by asking followupsTell the patient what condition they have
Retrieve and summarise relevant clinical literatureRecommend a medication or a dose
Cite where each part of the answer came fromPresent a context score as confidence in a diagnosis
State its scope in the interfaceLeave the patient to guess what kind of answer they are getting

The reasoning has three parts. First, a diagnosis depends on examination, history and tests that a conversation cannot supply, so any diagnosis the system produced would be built on missing evidence, however complete the intake score looked. Second, the harm is asymmetric: an unhelpful general answer costs the patient a little time, while a wrong diagnosis or medication suggestion can cost far more. Third, a narrow scope is one you can actually evaluate. "Does this answer accurately summarise the cited literature?" is a question you can test. "Is this diagnosis correct?" needs a clinician on every case.

The context score decides when the assistant has heard enough to search. Nothing in the system decides what is wrong with the patient, and that is deliberate.

Voice in, voice out

Patients can speak instead of type, and hear replies spoken back, alongside the text conversation. For intake this is more than a convenience. Typing a long, detailed description on a phone is a chore, and talking it through is often easier, especially for someone who is unwell or anxious. Every detail the patient volunteers is one the intake agent does not have to ask for in a followup, so the input channel and the context score are connected.

What carries over to other assistants

Very little of this is specific to healthcare. Any assistant that answers questions from a body of documents, whether that is policy, product manuals, contracts or support history, has the same three failure points and benefits from the same shape:

  1. 1Separate understanding from answering, and give the understanding stage its own score and its own stop condition.
  2. 2Gate retrieval on that score, and ask a followup when it is low instead of searching on a guess.
  3. 3Show the score and the stages to the user, so a followup reads as diligence rather than delay.
  4. 4Cite every answer, and test that the citations exist and support the text.
  5. 5Write the scope down in the interface, especially the things the assistant will not do, and keep it narrow enough to evaluate.

That is the pattern I bring to AI agent integration work in general: agents with one job each, explicit gates between them, visible working and a scope you can test. Rubi.AI is the clearest public example of it in my portfolio, and you can see the project summary on the work page.

If you have a document-heavy assistant in mind, or one already live that answers too quickly on too little and cannot show where its answers came from, I can scope the pipeline, the gates and the evals before any build starts, with a fixed price. Get a fixed-scope integration quote.

Questions people ask

What is a multiagent RAG pipeline?

It is a retrieval-augmented generation system where separate agents handle separate stages, such as understanding the question, retrieving sources and writing the answer. In Rubi.AI those stages are an intake agent, a retrieval agent and a summarization agent, each with one job and its own output that the next stage consumes.

Can an AI medical intake assistant diagnose patients?

Rubi.AI does not, by design: it gives general information drawn from clinical literature and does not diagnose or recommend medication, and the interface says so. A diagnosis needs examination, history and accountability that a chat assistant cannot provide, so the safer scope is helping a patient understand and describe their situation.

Why does an AI assistant need a context score before answering?

Because retrieval is only as good as the query it is given. If the assistant scores how much of the patient's situation it has actually extracted, it can ask a followup when the picture is thin, instead of searching on a vague description and returning a confident answer to the wrong question.

Why should a medical RAG assistant cite its sources?

Citations let a reader check where each statement came from, which matters more in health than almost anywhere else. They also make the system testable, because you can check that every cited passage exists in the retrieved literature and actually supports the sentence attached to it.

How long does it take to build a multiagent RAG assistant?

It depends mostly on the sources, the number of agents and how strict the evaluation has to be, so I scope it before quoting rather than giving a generic figure. The pipeline shape in this case study is a reasonable starting point for any assistant that must gather context first and answer with citations second.

Building something like this?

I design and ship these systems for clients: retrieval over private data, agents that complete real tasks, and the Laravel platforms underneath them.

Keep reading