Close the Loop.
An end-to-end design for behavioral health agents.
How Medera's behavioral health agents read the chart, write the visit back and turn every claim denial into a rule, and what keeps each of them in bounds: tokens in place of identities, evidence for every sentence, a crisis path with no language model, and one clinician approval for every write.
MederaPublished 13:33 explainerFull paper: 25-page PDF
Read the transcript
01 · Cold open · 0:00
An agent that drafts clinical notes can add a medication nobody mentioned.
Another, rewarded for paid claims, can learn to upcode. Medera is built so neither reaches a chart or a claim.
One visit, every system. Here's how Medera's behavioral health agents read the chart, write it back, and turn every denial into a rule.
02 · Where a paid claim goes missing · 0:25
Start with 1,000 claims leaving a practice.
About 116 come back denied the first time, and each one is worked again by hand.
Rework recovers most of them. About 27 are never paid at all.
And the target keeps moving: denial rates shift every year, and most providers say payer rules now change more often.
03 · The care team and the agents · 0:53
Collaborative Care runs on three people: the treating clinician, a behavioral health care manager and a psychiatric consultant.
Medera adds a layer of agents underneath them, coordinated by a Care Orchestrator.
The people stay the board: they sign, approve and review. The agents draft and check, and fixed code does the filing.
Each agent owns one stage of care: before, during and between visits, and after the visit.
04 · How agents fail · 1:26
Agents fail in known ways. Each failure below has a defense built in from the start.
Start with upcoding. Agents never see what a claim pays, and a rule can add a check, but never a code.
A model asked about something nobody discussed may invent an answer. So “not addressed in session” counts as correct.
Agents could signal each other through shared files, or edit their own logs.
So they talk only through one message broker, and only fixed code writes the log.
A model may flatter the clinician, or stay quiet about a problem.
So models are tested with planted errors they must catch, and any agent can hand a case to a person.
Models can behave differently when they know they're being tested.
So new agents run in shadow on real traffic first, and an outside evaluator checks the results.
05 · What the models never see · 2:26
Before any language model sees a word, an identity broker swaps names, birth dates and record numbers for tokens.
It already knows who the patient is from the chart, so it matches those exact strings first, then sweeps for patterns.
A named-entity pass catches what the chart doesn't list, like a sister's name or an employer.
Exact dates move by one fixed offset per patient, so the time between events stays true.
Models get the clinical content. They never get identities, credentials or raw video.
Only the write service, and only after a clinician approves, turns the patient token back into a real chart.
06 · Voice, measured · Research · 3:13
Nothing is recorded until the patient's consent is on file. Without it, capture never starts.
Session audio is captured in the browser and sent down two separate branches.
One branch transcribes: Medera's behavioral health speech model returns words, timestamps and who spoke.
Speech models can invent words during long silences, which are common in depression. So silence is trimmed first.
Passages about suicide, medications or doses also go through a second engine. If the two disagree, the clinician sees both.
The other branch never produces words. It measures the voice itself: pitch, steadiness, breathiness, pace and pauses.
Each branch is a fixed component with a defined input and output. Here's what each one takes, does and returns.
HIPAA lists voice prints as identifiers, so raw audio never reaches a language model. Only words and numbers move on.
07 · Camera pulse · Research · 4:20
When the clinician turns the camera on, a face mesh finds the forehead and cheeks in every frame.
Skin color shifts slightly with every heartbeat. Averaging those pixels gives three noisy color traces.
A POS projection and a heart-rate band-pass filter pull the pulse out of the noise. The spectrum's peak is the rate.
The frames never leave the device. Only the numbers do, and only when the signal is good enough to trust.
08 · How drafts are checked · 4:53
Language models do the writing. They draft the note from the de-identified transcript and the scores.
If the session never covered a topic, the draft says “not addressed in session”, and that counts as correct.
Then every sentence is scored against what was actually said. A medication nobody mentioned scores near zero.
Flagged sentences, and any about suicide risk, medications or diagnoses, go to independent checkers.
If the checkers disagree, the sentence goes to the clinician. Anything about safety goes to the clinician either way.
No check relies on a model's own reasoning. Each one reads the sentence and the evidence behind it.
Requiring agreement costs a few more human reviews, and buys far fewer silent errors.
09 · The crisis path · 5:49
A fixed classifier, not a language model, screens every transcript and patient message for suicide and self-harm risk.
In a session, a hit alerts the clinician at once, with the exact words that triggered it.
Between visits, a message that raises it gets a fixed reply pointing to the 988 Suicide & Crisis Lifeline.
The care team is alerted at the same moment. No agent writes that reply, and none can hold it back.
Any agent can also stop and hand a case to a person. “I can't do this safely” counts as a success, and every hand-off is tracked.
10 · Architecture, end to end · 6:33
Here is Medera's architecture end to end, following one session through it.
Capture starts only with consent. Narrow models turn sound and video into words and numbers, and a classifier watches for risk.
The identity broker swaps identifiers for tokens before any agent reads a word.
Agents draft, check and code. Every message between them passes through one message broker.
What they produce is a proposal. Fixed code checks it, logs it, and files it to EHRs and payers once a person approves.
11 · Who can touch what · 7:13
Now the boundary on one screen: who can touch what.
Agents get de-identified clinical text, and only what one task needs. Never identities, keys, raw audio or video.
Outside text, like a referral letter or an EHR screen, reaches an agent only as quoted data, never as instructions.
Agents hold no keys and run no tools. Even an approved action is carried out by fixed code, never by the agent.
Agents never see payment amounts or how they're graded, and can't write the log. People can read and replay all of it.
12 · Reading the chart · 7:56
The clinician opens Medera from inside the patient's chart. The EHR passes context, never a password.
Medera asks only for the permissions it needs: read what informs the note, create only what it files.
Standard FHIR searches pull the problem list, active medications and every past PHQ-9 score.
Identifiers go into the token map. The agents receive the clinical facts, never the access token.
13 · Writing back · 8:31
After the clinician approves, the write service files the note as a FHIR DocumentReference.
It's a conditional create keyed on the draft's ID, so a retry or a double-click can never file the note twice.
Scores, diagnoses, referral tasks and the biomarker report follow the same pattern, each to its own resource.
Then it reads each item back and compares fingerprints. A match turns green. Anything else goes to a person.
Every write gets a Provenance record: who authored it, which Medera agent assembled it, and when.
And the sync runs both ways. Changes made in the EHR flow back, so Medera's picture of the chart stays current.
14 · Glass In · 9:21
In the session, the clinician reviews the note and the suggested codes, then presses Glass In.
Glass In writes the visit into the practice's EHR as an unsigned draft, for the clinician to review.
Epic, Oracle Health and athenahealth are pinned. Any other EHR is one dropdown away. Here, that's Healthie.
The clinician can leave anything out. Whatever an EHR can't take is filed as a document, and shown here first.
If the patient isn't in that EHR yet, Glass In adds them first, through its own patient form. No portal invite, no message to the patient.
One confirmation, and each EHR gets its own job. The jobs run in parallel, and every item is read back before it turns green.
If an item doesn't verify, Glass In says exactly which one. Everything else still files.
Under the hood, every target is a versioned mapping: FHIR resources where there's an API, guided screen steps where there isn't.
15 · A Collaborative Care month · 10:31
Here is one patient's first Collaborative Care month, laid out the way the billing rules see it.
People do the clinical work. Agents prepare, measure, summarize and flag, and a person approves each output.
Minutes add up week by week. The month closes at 52.
At 52 minutes the month clears 99492's midpoint of 36. A payer that requires the full 70 needs a different code, and the rules know which payer is which.
Every requirement on this list becomes a check the claim has to pass before it's built.
16 · The denial loop · 11:13
Every claim lives in this loop: seven steps, and three ways back.
Before the first visit, the Eligibility agent confirms mental health coverage, and the Prior Auth agent secures the authorization this payer requires.
The claim is built and sent. The clearinghouse accepts it, but one field is missing: the authorization number.
The remittance comes back: paid zero. Its codes say exactly why, and the reader turns them into a work item with an owner.
Fix and resubmit gets this claim paid. The new rule makes sure the next claim can't leave without the number.
Some denials need an argument, not a fix. Those go back to the payer as an appeal, with the evidence attached.
17 · Inside the scrubber · 12:04
Before a claim leaves, it runs through rules written as plain, versioned configuration.
Each rule checks one thing and names its source, so a biller can see why it exists and an engineer can test it.
Yesterday's denial is today's rule: the missing authorization number now stops a claim before it's sent, and the fix is one line.
No model decides whether a claim goes out. Same claim, same rules, same answer, every run.
18 · Enterprise controls · 12:39
Autonomy is set per action, not per product. Anything risky stays low on the ladder.
Every new agent starts in shadow: it runs on real traffic, its output is logged, and none of it is used.
Monitors watch tool requests, write volume and EHR navigation, with an alert budget so every alert gets read.
Around it: tenant isolation, narrow permissions, a log only fixed code can write, kill switches and an outside evaluator.
19 · Close · 13:15
Put together: one visit reaches every system it touches, and every denial makes the next claim cleaner.
All care, no paperwork. That's Medera.
One loop, from the session to a paid claim.
Medera's behavioral health agents are built to close one loop. The session becomes a signed note, the note reaches the chart, and the claim is paid the first time.
When a payer still denies a claim, the reason is traced upstream and turned into a check, so the next claim never meets it. Four commitments hold the design together:
01
Verification over trust
No single model's output reaches the chart or a payer. Every sentence in a draft carries its evidence and is scored against it. Flagged and high-stakes sentences also need independent checkers from different model families to agree, and anything about safety goes to a person.
02
Narrow reads, approved writes
Each agent sees only what its task needs, with tokens in place of identities. Nothing reaches the EHR until a clinician approves it in Glass In. The write service, plain versioned code with no language model, then files it as an unsigned draft for the clinician's review and reads it back.
03
Fix denials upstream without gaming the record
The denial loop may add checks and change templates. It may never add codes, see payment outcomes, or change a rule without human approval.
04
A crisis path that never waits
A fixed classifier, not a language model, screens every transcript and patient message for suicide and self-harm risk. A hit reaches the clinician at once. Between visits, the patient gets a fixed reply pointing to the 988 Suicide & Crisis Lifeline, and the care team is alerted at the same moment.
The full paper takes each part of this design in turn, from what the models never see to the denial loop, rollout and measurement, with its tables, diagrams and sources. Request the PDF.
Read the whole design.
Every section, table and diagram, with the sources behind them, in a 25-page PDF. Tell us where to send it.
- Summaryp. 3
- Why one visit breaks in three placesp. 3
- Design principlesp. 4
- Tokens, not identities
- Proposals, not actions
- A record no agent can edit
- Checked, not trusted
- Autonomy earned, never assumed
- How agents fail, and what stops themp. 5
- System overviewp. 8
- What the models never seep. 9
- Who can touch whatp. 10
- Bidirectional EHR syncp. 11
- Consensus and evidencep. 17
- The crisis pathp. 18
- The revenue cycle loopp. 18
- Collaborative Care: where the denials hidep. 20
- Killing denials without gaming the recordp. 21
- Enterprise controlsp. 22
- Rollout and measurementp. 23
- Limits and open questionsp. 24
- Sourcesp. 25








