RAG, assistants and agents
On its own, a language model answers from memory. In hospitals, answers must come from the patient's record, from current guidelines and from local procedures. Retrieval-augmented generation (RAG) connects the model to those sources. Agents go one step further and let the model take actions.
- RAG grounds a language model in current, local documents and makes sources checkable.
- Its weak point is retrieval: missing or badly indexed documents lead to silent omissions.
- Prompts are configuration: they must be fixed, versioned and tested.
- Agents act, so they need permissions, logs, approval points and an off switch.
Got these four points? You have the essentials. Read on for the explanations, examples and traps.
Retrieval-augmented generation (RAG)
- Retrieve. When a question arrives, a search component finds the most relevant documents: notes from the patient's record, a hospital procedure, a guideline, articles.
- Augment. Those documents are placed in the model's context window with the question and instructions such as “answer only from these documents and cite them”.
- Generate. The model writes the answer, ideally with references to the documents it used, so the clinician can check them.
What RAG improves, and what it does not
RAG improves
- Answers are grounded in current, local documents
- Sources can be shown and checked
- No need to retrain the model when documents change
- Access can follow the user's permissions
RAG does not solve
- If retrieval misses a document, the answer silently omits it
- The model can still misread or misquote a source
- Contradictory or outdated documents produce confused answers
- Poor indexing (scanned PDFs, missing document types) creates blind spots
When a hospital pilots a record assistant built on RAG, a typical pattern is that the most serious complaints concern omissions rather than invented facts: a document type that was never indexed, a report that arrives through another interface, a scanned letter the search cannot read. Before blaming the model, check what the retrieval step can actually see.
Prompts and system instructions
The text that tells the model how to behave is the prompt. In a hospital product, most of it is hidden: a system prompt written by the developer sets the role, the tone and the rules (“cite sources”, “do not give dosing advice”, “answer in the user's language”). The user's question is added on top. Small changes to prompts can change behaviour significantly, which is why a validated product fixes and versions its prompts like any other configuration.
Text inside a document can contain instructions aimed at the model (“ignore your rules and…”). If an assistant reads external documents or emails, a malicious or simply odd document can change its behaviour. Well-designed systems treat retrieved text as data, not as instructions, and restrict what the assistant can do.
From assistants to agents
An assistant answers. An agent also acts: it can call tools such as a search engine, a calculator, the scheduling system or an order-entry form, decide on the next step, and chain several steps to complete a task. Examples include agents that prepare prior authorisation files, schedule appointments by phone, or pre-fill orders for a clinician to sign.
Reads and answers; the human does everything else.
Human checks the answerPrepares a document or order; the human edits and signs.
Nothing leaves without signatureExecutes multi-step tasks; asks before irreversible actions.
Permissions, logs, approval pointsActs alone within a defined scope.
Strict scope, monitoring, kill switch; rare in careThe more an AI acts, the more important become permissions (what can it access and change?), traceability (logs of every action) and the ability to stop it.
An assistant's answer about a patient's allergies cites three documents, but the most recent allergy record is missing. Is this a hallucination or an omission, and where in the RAG chain would you look for the cause?
Show the answer
It is an omission. Look at retrieval: was the latest allergy record indexed, was it available through the interface, was it filtered out by the search, or excluded by the permissions or date range?
If you can answer out loud in a minute, you have understood the chapter.
Adapted from AI Basics for Hospital Professionals, edition 1, November 2026. Educational content only: not legal, regulatory or clinical advice, and no product recommendation. Facts and dates checked as of November 2026; verify regulatory dates at the official sources.
