Trusted Mini-Agents
Engineering Hallucinations Out of AI Workflows
Introduction
For high-stakes work that needs to be correct, generative AI needs guaranteed safeguards. Large language models (LLMs) inevitably hallucinate in surprising ways, no matter how good your prompts and skills may be. In the life sciences, for example, LLM hallucinations risk undermining the correctness of statistical deliverables, impacting the health and safety of millions of patients.
This guide proposes a strategy to achieve trust without sacrificing the convenience of LLMs. We introduce trusted mini-agents: least-privilege AI systems that engineer out hallucinations and excel in precision scenarios.
Definition
A trusted mini-agent is an agent that obeys the following three rules:
- Trusted tools directly produce all results.
- Each result only comes from one trusted tool.
- Inputs to trusted tools have trusted human oversight.
Impact on users
Instead of:
Are these results correct?
users ask:
Is the agent solving the right problem?
which is much easier to verify.
Workflow
The trusted mini-agent workflow combines the power of modern agents with the safeguards of traditional software engineering:

After an initial prompt, the work begins with the agent loop. Here, the LLM ponders and delibererates uninterrupted and unsupervised, potentially with the aid of untrusted tools (e.g. web search, back-of-the-envelope calculations, etc.) which are structurally incapable of producing final results.
Ultimately, the LLM proposes inputs to one or more trusted tools that perform critical computations such as modeling and simulation. Those inputs reflect how the LLM frames up the problem and sets up an advanced computation. Since they are about overall framing and human intent, they are easy to check for hallucinations, especially if the system for oversight is carefully structured, with realistic expectations about human understanding, attention, and fatigue.
After a trusted system of review, the LLM-generated inputs move to a set of designated trusted tools that cannot be bypassed. Those trusted tools perform important computations such as statistical analysis, modeling, and simulation. Results from such computations are usually too complex for humans to check, but they are guaranteed to come from trusted tools on verified inputs. Conditional on good inputs, hallucinated results are structurally impossible.
Who this is for
This guide is for quantitative scientists and programmers who implement AI tools for high-stakes work. Although the underlying concepts generalize to other programming languages and frameworks, all the examples are in R and Shiny. No prior experience with ellmer or shinychat is necessary.
Contents
After introducing the concepts, the guide builds a minimalist example of a trusted mini-agent, then concludes with a motivating example.
- Chapter 1: Deconstructing agents. An overview of agents, their relevant components, and how they work together, laying the groundwork for trusted mini-agents in later chapters.
- Chapter 2: Controlling hallucinations. An overview of the trusted mini-agent pattern and how it controls hallucinations, featuring the concept for the weather agent in Chapter 4.
- Chapter 3: A trusted mini-agent template. A minimal Shiny app that can be developed into a trusted mini-agent.
- Chapter 4: Registering tools in a full working example. A full working trusted mini-agent that demonstrates the concepts.
- Chapter 5: Example: CRAN download metrics. A motivating example to show the practical usefulness of trusted mini-agents.
Acknowledgements
- Simon Couch and Sara Altman covered similar topics in their 2026 talk at R/Pharma genAI Day. In their presentation, they recommended: “Design the scaffold so that it matters less if [LLMs are] wrong.” The trusted mini-agent pattern attempts to explore this idea to its fullest extent.
- Hadley Wickham’s keynote at useR! 2025 described the central role of tools in the development of agents. This talk was the original spark that led to the strategy in this guide.
- Early one-on-one conversations with Joe Cheng helped clarify the different roles and uses of registered tools versus structured data in
ellmer-powered agents.