In medicine, the world model is the differential held open. Each hypothesis carries what is wrong, how sure the agent is, and on what evidence, kept live until a test resolves it rather than snapping shut on the first plausible answer. A patient comes in with an elevated HbA1c and a normal fasting glucose: type 2 diabetes, pre-diabetes, or something else? A belief state that lives outside the model keeps that differential live, each hypothesis pinned to the findings that move it, and every step traces to evidence a clinician can inspect and overturn before anything is ordered.
The world
The environment is the patient's clinical picture: the presenting complaint, active conditions, the medication list, and the relations between them. Polyuria and weight loss point toward one diagnosis; metformin and a sulfonylurea interact in ways that bound what you can safely add. Ground truth is the objective record, the labs and imaging and vitals you can re-pull. The patient's stated preferences sit on the other side of a firewall, present in the world model but never weighed as evidence.
What streams in
Clinical signal arrives continuously, and each arrival is an observation:
- lab panels and vitals
- imaging and pathology reports
- clinical notes and history
- published studies and guideline updates
Every finding strengthens some hypotheses and weakens others. The model records which finding did the moving, so when a posterior shifts you can name the lab that shifted it.
The belief state
A good diagnostician resists premature closure, and so does the agent. It holds the competing hypotheses side by side, each carrying an explicit posterior and its own evidence list, and it tracks the single missing test whose result would most separate the two leaders.
1┌──────────────────────────────────────────────────────────────┐
2│ DIFFERENTIAL DIAGNOSIS │
3│ │
4│ ● Type 2 diabetes 72% │ 4 supporting │
5│ ├─ Elevated HbA1c (measurement) │ 1 contradicting │
6│ ├─ Family history (assertion) │ │
7│ ├─ BMI > 30 (measurement) │ │
8│ └─ Normal fasting glucose (⚠) │ │
9│ │
10│ ● Pre-diabetes 61% │ 3 supporting │
11│ ├─ Borderline HbA1c │ │
12│ ├─ Normal fasting glucose │ │
13│ └─ Age and risk factors │ │
14│ │
15│ ● Stress response 28% │ 1 supporting │
16│ └─ Recent life event (⚠) │ 2 contradicting │
17│ │
18│ Gap: oral glucose tolerance test not performed │
19│ Resolving it would settle A vs. B. │
20└──────────────────────────────────────────────────────────────┘Read it top to bottom. Type 2 diabetes leads at 72 percent, but the normal fasting glucose is flagged as contradicting it, which is exactly the kind of tension a memory store would flatten into a note and forget. Pre-diabetes sits close behind on overlapping evidence. The OGTT surfaces as the next-best test on its own, because the model can compute which missing result would most reduce uncertainty between the two leaders rather than waiting for a clinician to think of it. The percentages are independent posteriors per hypothesis, not a partition (they need not sum to 100 percent), so several can be partially supported at once.
What we're after
The agent is not chasing certainty for its own sake. The goal is to narrow the differential safely toward a diagnosis, and the engine ranks moves against that intent rather than against raw uncertainty. The most useful next test is the one that most separates the leading hypotheses, surfaced and ordered only with a clinician's approval. The limiting factor is the gap whose resolution would do the most separating, which is why the OGTT rises to the top and a low-yield repeat panel does not.
| Goal | Narrow the differential safely toward a diagnosis. |
| Success | The next test is the one that most separates the leaders, ordered only with clinician approval. |
| Limiting factor | The gap whose resolution most separates the leading hypotheses. |
The policy
Clinical reasoning carries the strictest policy of any world here, and you encode it in how the agent weighs what it sees:
| Policy bucket | In a clinical picture |
|---|---|
| Invariants | Do no harm. Stay within scope of practice; a human clinician owns the decision. |
| Source hierarchy | Strength of evidence: an RCT outranks a cohort study, which outranks a case report; a larger, better-powered trial outweighs a smaller one. You express that ranking in how confidently you observe each source. |
| Conventions | Established clinical guidelines for the presentation. |
| Avoid | Letting a preference act as evidence. This is the is/ought firewall. "I want to avoid surgery" is a preference, and it must not raise confidence that surgery is unnecessary. A diagnostic finding is evidence, and it updates the picture. The firewall is how you model the two: preferences shape goals, only findings move posteriors. |
The actions
Sort the agent's moves by how much damage a wrong one could do:
| Action | Safety class | Effect |
|---|---|---|
suggest-differential, summarize-history | info | Read-only. Surfaces; decides nothing. |
flag-interaction, update-record | mutates | Annotates the record. |
order-test, recommend-treatment | needs-approval | Gated on a clinician. |
Today, policy and actions are a modeling lens you hold rather than machinery the engine runs. You encode the invariants, the source hierarchy, and these safety classes in how you observe and act. The engine does not yet take a registered policy; a declarative config surface is on the roadmap. Read these tables as the contract your agent enforces, not one the engine enforces for you.
The agent surfaces and ranks; a clinician acts. The verdict is the product here, and the evidence chain is what makes it trustworthy. Because every belief carries its provenance, a clinician can correct the picture before it informs a decision rather than discovering the error in the chart afterward.
Plan & act
1import Beliefs from 'beliefs'
2
3const beliefs = new Beliefs({
4 apiKey: process.env.BELIEFS_KEY,
5 agent: 'clinical-agent',
6 namespace: 'patient-123',
7 writeScope: 'space',
8})
9
10// 1. Orient: read the current picture; the ranked next moves ride back on it.
11const context = await beliefs.before('What would most clarify this differential?')
12const [move] = context.moves // top-ranked, already in hand; no extra call
13// → { action: 'gather_evidence', subType: 'order-ogtt', valueOfInformation: 0.8, ... }
14
15// 2. Act. order-ogtt is needs-approval, so a human gates it.
16// A clinician approves; the order runs and results return as evidence.
17const labs = await runApprovedTool(move.subType) // 'order-ogtt' → a clinician-approved order
18
19// 3. Fold the result back in: it becomes the next observation.
20await beliefs.after(labs.text, { source: 'Lab panel 2026-03-15' })The OGTT result re-weights the hypotheses; the patient's stated wish never does. That is the firewall working in the loop. The trace is what backs the verdict, showing exactly which finding moved which hypothesis, so the reasoning is auditable end to end.
Emerging: plan several moves ahead
As a workspace accumulates outcomes, the agent can forecast which workup most reduces diagnostic uncertainty across the next several steps. Call beliefs.forecast.predict(['order-ogtt', 'repeat-hba1c', 'lipid-panel']) and it reports low confidence honestly until it has the resolved history to calibrate against.
