%%{init: {'theme':'base', 'themeVariables': {'lineColor':'#4B5563','edgeLabelBackground':'#ffffff'}}}%%
flowchart LR
subgraph AgentLoop["Agent Loop"]
direction TB
Model["Model"]
UT["Untrusted<br>Tools"]
Model -->|"Autonomous<br>reasoning"| UT
UT --> Model
end
HR["Human<br>Review"]
subgraph Trust["Trust"]
direction TB
TT["Trusted<br>Tools"]
TR["Trusted<br>Results"]
TT -->|"Nontrivial<br>Computation"| TR
end
AgentLoop -->|"Proposed Inputs"| HR
HR -->|"Rejected Proposals"| AgentLoop
HR -->|"Reviewed Inputs"| TT
style Model fill:#1F3A63,color:#ffffff,stroke:#1F3A63
style UT fill:#6B2020,color:#ffffff,stroke:#6B2020
style HR fill:#166534,color:#ffffff,stroke:#166534
style TT fill:#166534,color:#ffffff,stroke:#166534
style TR fill:#166534,color:#ffffff,stroke:#166534
style AgentLoop fill:#FDE8E8,stroke:#9CA3AF
style Trust fill:#F3F4F6,stroke:#9CA3AF
Trusted Mini-Agents
Engineering AI Errors Out of Agentic Workflows
An introduction to trusted mini-agents: least-privilege AI systems that engineer AI errors out of high-stakes agentic workflows.
Introduction
For high-stakes work that needs to be correct, generative AI needs guaranteed safeguards. AI models produce errors that cannot be prevented through the engineering of prompts or context. In the life sciences, for example, AI model errors 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 AI models. We introduce trusted mini-agents: least-privilege AI systems that engineer out AI errors 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 AI model ponders and deliberates 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 AI model proposes inputs to one or more trusted tools that perform critical computations such as modeling and simulation. Those inputs reflect how the AI model 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 AI errors, 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 AI-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, AI-generated errors in the 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, the implementation examples are in R and Shiny for R or Python and Shiny for Python. No prior experience with ellmer, chatlas, or shinychat is necessary.
Contents
Concepts. The abstract ideas behind trusted mini-agents, independent of any particular programming language or framework.
- Deconstructing agents. An overview of agents, their relevant components, and how they work together, laying the groundwork for trusted mini-agents in later chapters.
- AI errors. How AI errors manifest in agents, and how to harden an example weather agent against them.
- The formal definition. The formal definition of a trusted mini-agent, including the three rules, the workflow, and when trusted mini-agents are useful.
Implementation in R. A concrete R and Shiny implementation of trusted mini-agents, building on the concepts above.
- A trusted mini-agent template. A minimal Shiny app that can be developed into a trusted mini-agent.
- Example: weather agent. A full working trusted mini-agent that gets the weather.
- Example: simulation. A motivating example to show the practical usefulness of trusted mini-agents.
Implementation in Python. A concrete Python and Shiny for Python implementation of trusted mini-agents, building on the concepts above.
- A trusted mini-agent template. A minimal Shiny for Python app that can be developed into a trusted mini-agent.
- Example: weather agent. A full working trusted mini-agent that gets the weather.
Appendices. Related work that adapts the ideas above.
- External examples. Projects that borrow trusted mini-agent principles.
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 [AI models 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.