Mendari
Open-source governance and evaluation for healthcare AI agents.
Mendari wraps an AI agent (an LLM behind a prompt, a LangGraph workflow, an HTTP service of your
own) in a deterministic governance engine. Every call to the agent ends in one of four explicit
outcomes, AUTO, HUMAN_REVIEW, ABSTAIN or BLOCK, decided by a policy you can read, capped
by the agent's risk level, and written to an append-only, hash-chained audit trail. The same
engine evaluates the agent on labelled cases and publishes it, with its evaluations, as a signed
archive that anyone can pull and verify.
It is built for two groups, and for the loop between them:
- Developers build an agent, run it through the engine and publish every evaluation with
it: how each configuration and model did on the same cases, so whether one clearly did
best is there to read.
- Hospitals adopt an agent that already comes with its evaluations and a governance
structure, try it in shadow on their own workflows (a person decides every case, and the
engine records what the agent would have automated), then share their results back as signed
counts, never cases.
Status: research preview (0.1.2). Everything here runs on synthetic
data. Mendari is not a medical device, and it must not be used with real PHI or real patients:
its external security review has not happened yet (Status and limits).
Documentation: mendari-hq.github.io/mendari: the guides, the agent manifest's
specification and the API.
your AI agent (LLM, LangGraph, HTTP service)
│ answers the questions the manifest declares, with a confidence
▼
input schema ──► agent ──► policy: rules, thresholds, risk-level caps ──► AUTO | HUMAN_REVIEW | ABSTAIN | BLOCK
│
audit trail · review queue · FHIR Task
The four outcomes
| Outcome |
Meaning |
AUTO |
Acted on without a person, within the agent's risk cap and confidence policy. |
HUMAN_REVIEW |
A person decides, with the agent's recommendation in front of them. |
ABSTAIN |
No recommendation: the agent was not confident enough, or did not answer. |
BLOCK |
The input failed its schema or a guardrail, and the agent never saw it. |
The policy turns the agent's answers into an outcome in three steps: named rules first (in the
demo agent, a message that may describe same-day symptoms goes to a nurse as HUMAN_REVIEW,
priority urgent), then confidence thresholds on the primary question, then caps. Caps only
lower automation: a per-label limit, a failed or timed-out agent call, or the risk level can
turn AUTO into HUMAN_REVIEW, never the reverse.
The risk level is declared in the agent's manifest and enforced by the runtime, not by the agent
(ADR-0002):
| Level |
Kind |
Automation |
| 0 |
Administrative (scheduling, routing, billing) |
AUTO allowed by policy |
| 1 |
Clinical information processing |
AUTO allowed; audited |
| 2 |
Clinical support |
Human review by default; AUTO needs a recorded governance approval |
| 3 |
Patient-specific prediction |
As level 2, with stronger validation expected |
| 4 |
Time-critical, diagnostic or treatment |
Never automated |
What an agent does is gated too. An agent may ask to have something done besides answer: a
message put in a queue, a reply sent, an order placed. Its manifest declares each action with
an effect, the agent proposes actions with its answers, and the decision's outcome decides what
may be done with each. Mendari authorizes an action and records that it did; it runs none, and
your caller runs only what was released (Governing actions).
| The decision is |
read, draft |
write, contact |
order |
AUTO |
released |
released |
never: proposing one sends the decision to a person |
HUMAN_REVIEW |
released |
held for the reviewer |
held for the reviewer |
ABSTAIN |
released |
blocked |
blocked |
BLOCK |
blocked |
blocked |
blocked |
The gate is the runtime's, like the risk caps: a manifest can tighten it (allow_auto: false)
and nothing loosens it. An action the agent never declared is blocked.
The confidence the thresholds cut on can be checked: mendari calibrate fits an external
agent's confidence on labelled cases, for the version its service reported then, and when the
service reports another version nothing is automated until it is calibrated again. A second
signal (each case asked several times, or a second model that checks the first) sends a
decision to a person when the answers disagree, and never raises automation
(Calibration and a second signal).
Install
Mendari needs Python 3.11+. One install brings the command line and the server
(mendari serve), with no extra to name:
pip install mendari
To work on Mendari itself, or to run the commands below as they are written, clone the
repository and use uv:
git clone https://github.com/mendari-hq/mendari.git
cd mendari
uv sync # the package, the server, and the test and lint tools
Without uv, in the clone, into any Python 3.11+ virtual environment:
pip install .
mendari --help lists the commands to start with, and mendari help all every one.
Five minutes: from the demo to your own agent
The commands are written for a clone, as CI runs them. Installed with pip install mendari,
leave out uv sync and uv run, and where a command names the demo agent's folder
(agents/portal-message-agent), name the agent instead (mendari/portal-message-agent).
1. Run the demo
Mendari bundles one agent, mendari/portal-message-agent
(agents/portal-message-agent/).
It reads a patient portal message, says what the patient asks for (a refill, an appointment,
something else) and whether the message describes symptoms that need attention today. It
answers offline from canned answers, so nothing here needs a key or a network. Like everything
in this repository it is a Synthetic example. Not clinically reviewed. Not for patient care.
uv sync
uv run mendari demo
The demo decides six messages and shows what the agent asked to do with them:
released assign_queue (write) with the AUTO decision on message 1
held send_acknowledgement (contact) message 3 waits for a reviewer
released send_acknowledgement (contact) the reviewer confirmed it
blocked an action the agent never declared asked for message 1
It then works the review queue, verifies the audit chain, evaluates
the agent on 600 synthetic messages and says not ready: the canned answers do not detect 33
of the 114 urgent messages, those worded as a patient might, and 9 of them would have been
automated, so no person would have read them. That is on purpose: the evaluation is there to
catch it before anything decides alone. Its
operating point
adds that no automation threshold keeps such critical misses to 1% with 95% confidence: the fix
is the agent, not the threshold. And a
probe
rewrites cases in ways that keep their meaning (a typing error, a line break, an instruction
slipped in) to find the failures nobody wrote a case for. Last, it grades
what the agent wrote
against a rubric: a judge's grades are shown only for the criterion on which it agrees with
the graders, and withheld for the rest. The demo's graders are simulated and its judge's grades
are canned, and it says so.
2. Scaffold, validate, test and evaluate your own
uv run mendari new my-agent --id my-clinic/my-agent # a working copy of the demo agent, under your id
uv run mendari validate my-agent # the manifest and every file it names
uv run mendari test my-agent # its behaviour tests
uv run mendari eval my-agent --dataset examples # accuracy, calibration, outcomes, the operating point
uv run mendari eval my-agent --dataset examples --provider reader=rules # the keyword-rules variant, same cases
uv run mendari probe my-agent # its failures; --write keeps each as a test
The folder is plain text:
my-agent/
├── agent.yaml the agent's manifest: id, risk level, questions, the agent slot, policy
├── schemas/input.schema.json what a valid input looks like (anything else is BLOCK)
├── fixtures/mock_agent.json canned agent answers, used while no live agent is set
├── logic/rules.yaml a keyword-rules variant to compare the agent with
├── data/examples.jsonl labelled cases for `mendari eval`
├── tests/cases.yaml behaviour tests for `mendari test`
└── .github/workflows/mendari.yml the same checks on every change (no part of the agent)
The manifest declares questions, not models: each question has a fixed set of answers with
criteria written in words, and the policy is written against those answers. A slot answers
them, and each of its variants is one of four types: rules (weighted patterns), llm (a model
behind a prompt), agent (your service, over HTTP) or check (one variant answers, a second
checks it, and a person decides where they disagree). Edit the questions and the policy for
your own task: mendari validate says what is wrong, by file and field, and mendari eval gives
each figure as k of n with its exact 95% interval (twelve cases are a smoke test, not an
estimate). The
authoring guide
explains every section, and
the spec
specifies it.
In CI. The workflow uses Mendari's GitHub Action: on a pull request or a push to main it
validates, tests and evaluates the agent, writes the figures and the operating point to the
job's summary, and fails the job when a limit you state is not met or the result is worse than
a baseline. It needs no secret, and resolves once a release is tagged (none is yet)
(Evaluating an agent on every change).
3. Put a real model behind it
The answers come from a service you run: Mendari sends it one POST per decision, with the
questions and the input fields the manifest allows, and checks every answer. Three starters
speak that contract, each with one function to replace:
examples/http-agent,
examples/langgraph-agent
and examples/claude-agent.
cd examples/http-agent
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
AGENT_TOKEN=a-long-random-string .venv/bin/uvicorn api.index:app --port 8787
In a second terminal, in the clone, the same commands now call it instead of the canned answers:
MENDARI_AGENT_URL=http://127.0.0.1:8787/decide MENDARI_AGENT_TOKEN=a-long-random-string \
uv run mendari eval my-agent --dataset examples
A wrong, missing or late answer is a provider failure, and the decision goes to HUMAN_REVIEW
or ABSTAIN: an unreachable agent never automates
(the contract).
Measured through Mendari on the demo agent's 600 synthetic test messages (2026-11-21, exact 95%
intervals):
|
Canned answers (offline) |
claude-agent (live) |
| Request correct |
549 of 600 [89.0-93.6%] |
598 of 600 [98.8-99.96%] |
| Urgent messages caught |
81 of 114 [61.8-79.2%], 9 automated |
114 of 114 [96.8-100.0%], none automated |
| Automated and wrong |
9 of 600 |
0 of 600 |
| Cost per decision |
$0 |
$0.0075 |
| Latency, median / 95th percentile |
under 1 ms |
2.2 s / 4.2 s |
The set is synthetic, built from fixed phrase lists: it shows how the evaluation tells two
configurations apart, not how either would do on real patients.
4. Serve it and open the console
MENDARI_AGENTS_PATH=my-agent uv run mendari serve --db var/demo.db # http://127.0.0.1:8000
The Governance Console at http://127.0.0.1:8000 shows each agent's Decision Card, the review
queue, the audit trail, evaluations and monitoring; the demo agent is served beside yours (set
MENDARI_AGENT_URL as in step 3 and the server calls your live agent). From a second terminal,
ask for a decision:
curl -sS -X POST http://127.0.0.1:8000/api/agents/mendari/portal-message-agent/decide \
-H 'content-type: application/json' \
-d '{"message": {"body": "Please refill my inhaler. Also I have had chest pain since last night."}}'
The answer is the decision ("outcome": "HUMAN_REVIEW", "priority": "urgent"): the rule
same-day-symptoms sends a refill request that mentions chest pain to a nurse. It is now in the
review queue (GET /api/review) and the audit trail (GET /api/audit/{id}). The JSON names the
agent under agent: its id, version and digest. The server is open by default, for local use,
and documents its API at /docs; with sign-in on, canned answers never automate.
The same decision from Python:
from mendari import Decision
agent = Decision.from_hub("mendari/portal-message-agent")
result = agent({"message": {"body": "Please refill my inhaler. Also I have had chest pain since last night."}})
result.outcome # Outcome.HUMAN_REVIEW
result.recommendation # 'refill'
result.priority # Priority.URGENT
result.reasons # ('rule same-day-symptoms: The message may describe symptoms that need a nurse today.',)
Another AI agent calls the same decisions as tools: mendari mcp --db var/mcp.db is a
Model Context Protocol server on stdio.
The Agent Hub: publish and pull