Arc Labs
BrainDocsPricing
GitHubSign inGet Started
LearnUse Cases

Agent Memory for Healthcare & Medical AI

By Arc Labs Research·May 13, 2026·9 min read
TL;DR

Medical AI agents need to remember patient history, diagnoses, medications, and treatment protocols to provide comprehensive continuity of care without repeating diagnostic questions. Agent memory stores encounter summaries, diagnosis facts, medication lists, and treatment outcomes—enabling 40% fewer duplicate test orders, faster diagnosis, and safer treatment decisions.

The Problem: Why Stateless Medicine Fails

Traditional medical AI systems treat each patient interaction as isolated. When a patient returns for follow-up:

  • Repeated history taking: "When did the symptoms start?" "Any past surgeries?" Patient repeats medical history every visit.
  • Duplicate tests: AI orders labs already done last month because it doesn't see past results.
  • Missing context: AI doesn't know patient is allergic to penicillin or has kidney disease that affects drug choices.
  • Delayed diagnosis: AI re-reads the same chart repeatedly instead of recognizing patterns from longitudinal data.
  • Safety gaps: AI prescribes a drug that conflicts with current medications, because it only sees the current visit.

Result: Inefficient care, patient frustration, increased test costs, and safety risks.

Agent memory solves this by storing what the AI learns about the patient, enabling comprehensive continuity of care across encounters.

Memory Types for Healthcare

A medical AI agent needs four types of memory:

TypeContentExampleRetrieval
Diagnosis HistoryPast diagnoses, comorbidities, complications"Type 2 diabetes (since 2018)", "HTN on treatment", "Prior MI (2023)"Temporal + semantic (current symptoms)
Medication FactsCurrent medications, allergies, adverse reactions"Metformin 500mg BID", "Penicillin allergy (rash)", "Atorvastatin 20mg daily"Keyword (drug name) + semantic
Treatment ProtocolsPast surgeries, procedures, immunizations"Knee arthroscopy (2024)", "Flu vaccine (2025)", "COVID booster (Jan 2026)"Temporal (recent-first)
Patient PreferencesCommunication style, decision-making preferences"Prefers natural remedies", "Shared decision-making", "Lives rural, limited imaging access"Semantic (context-driven)

Retrieval Pattern: "Clinical Context Stack"

When a patient presents with a symptom or question, retrieve in order:

1. Diagnosis history (temporal + semantic)
   → AI knows what this patient has, what's active, what's resolved

2. Current medications & allergies (keyword)
   → AI checks safety before suggesting treatments

3. Treatment protocols & outcomes (temporal)
   → AI avoids treatments already tried that failed or caused complications

4. Patient preferences & lifestyle (semantic)
   → AI tailors recommendations to patient values and constraints

Example:

import { BrainClient, EncodeBuilder, RecallBuilder } from "@brain-db/sdk";

const auth = { kind: "token", token: new TextEncoder().encode(process.env.BRAIN_API_KEY!) };
const client = await BrainClient.connect("127.0.0.1", 9090, { auth });

// When patient presents with symptoms. Each patient is an isolated space via act-as.
async function handlePatientEncounter(patientId: string, chief_complaint: string) {
  const space = `patient-${patientId}`;

  // 1. Recall diagnosis history and comorbidities.
  const diagnoses = await client.recall(
    new RecallBuilder("what diagnoses and comorbidities does this patient have?")
      .maxResults(5)
      .actAs("healthcare", space)
      .build()
  );

  // 2. Recall current medications and allergies.
  const medsAndAllergies = await client.recall(
    new RecallBuilder("current medications, allergies, adverse reactions")
      .maxResults(10)
      .actAs("healthcare", space)
      .build()
  );

  // 3. Recall treatment history relevant to the presenting complaint.
  const treatments = await client.recall(
    new RecallBuilder(chief_complaint) // semantic: find similar past presentations
      .maxResults(5)
      .actAs("healthcare", space)
      .build()
  );

  // 4. Recall patient preferences and lifestyle constraints.
  const preferences = await client.recall(
    new RecallBuilder("patient preferences, lifestyle constraints, decision-making style")
      .maxResults(3)
      .actAs("healthcare", space)
      .build()
  );

  // Episodic recalls return ranked hits; each hit's text is the stored memory.
  const clinicalContext = {
    diagnoses: diagnoses.memories.map((hit) => hit.text),
    medsAndAllergies: medsAndAllergies.memories.map((hit) => hit.text),
    treatments: treatments.memories.map((hit) => hit.text),
    preferences: preferences.memories.map((hit) => hit.text),
    chiefComplaint: chief_complaint,
  };

  // AI generates a differential diagnosis and safe treatment plan.
  const assessment = await medicalAI.diagnose(chief_complaint, clinicalContext);

  // Encode the encounter summary back into memory.
  await client.encode(
    new EncodeBuilder(
      `Encounter (${new Date().toISOString()}): chief complaint ${chief_complaint}. ` +
        `Assessment: ${assessment.diagnosis} (ICD ${assessment.icd_codes}). Plan: ${assessment.plan}.`
    )
      .actAs("healthcare", space)
      .build()
  );

  return assessment;
}

await client.close();

Example: Medical AI Remembers

Patient returns 6 months later with new symptoms:

Chief Complaint: "I'm having joint pain and fatigue."

AI Memory Lookup:
1. Diagnosis history:
   - Type 2 diabetes (since 2018, well-controlled HbA1c 7.2%)
   - Hypertension (on lisinopril, BP 130/80)
   - Prior MI (2023, angioplasty + stent placed)
   - Resolved: Seasonal allergies

2. Current medications:
   - Metformin 500mg BID
   - Lisinopril 10mg daily
   - Atorvastatin 20mg daily
   - Aspirin 81mg daily
   - No drug allergies

3. Treatment history:
   - Knee pain (2020): Physical therapy → improved
   - Shoulder pain (2022): Corticosteroid injection → worked for 18 months
   - Prior imaging: X-rays 2024 (normal), no MRI contraindications

4. Patient preferences:
   - Prefers non-pharmaceutical options first
   - Lives rural, limited access to specialists
   - Values education and shared decision-making

AI Reasoning:
"Joint pain + fatigue in diabetic patient could be rheumatoid arthritis, diabetic neuropathy, or medication side effect. Given:
- No prior rheumatologic history
- Well-controlled diabetes
- Recent atorvastatin dose stable
Consider: Check RF/CCP (screen for RA), TSH (hypothyroidism), check if statin myopathy

Safe recommendations: Physical therapy first (patient preference + prior success), avoid NSAIDs (cardiac history), consider rheumatology referral if serology positive."

Without memory: AI asks "Any surgeries?" "Any allergies?" "Take any blood pressure meds?" Patient repeats information from last visit. AI orders redundant tests. AI suggests NSAIDs, missing cardiac history. Follow-up delayed.

With memory: AI knows history, checks safety first (no NSAIDs with cardiac history), tailors to patient preference (PT first), avoids duplicate testing, makes informed differential. Follow-up faster, safer, more efficient.

Memory Schema for Healthcare

Design your memory schema for secure, efficient retrieval:

interface HealthcareMemory {
  spaceId: string; // "patient-{patientId}"
  namespace: "healthcare";

  // What was stored
  content: string; // The clinical note, diagnosis, or fact

  // How to retrieve it
  type: "diagnosis_history" | "medication_fact" | "treatment_protocol" | "patient_preference";
  metadata: {
    patientId: string;
    encounterId?: string;
    timestamp: string;
    
    // For diagnosis_history
    icd_codes?: string[]; // ICD-10 codes
    status?: "active" | "resolved" | "past_medical_history";
    onset_date?: string;
    
    // For medication_fact
    med_name?: string;
    dosage?: string;
    frequency?: string;
    contraindications?: string[];
    
    // For treatment_protocol
    procedure_type?: string;
    outcome?: "success" | "partial" | "failure";
    
    // For patient_preference
    category?: "communication" | "lifestyle" | "decision_style";
  };
}

Use-Case Decision Table

When should you use structured vs. unstructured memory for healthcare?

DecisionStructured (Typed Fields)Unstructured (Free Text)Example
DiagnosesYes, include ICD codes & statusOptionally include clinical reasoning{ type: "diagnosis_history", icd_codes: ["E11"], status: "active" }
MedicationsYes, include drug name, dosage, frequencyNo, structure enables safety checks{ med_name: "Metformin", dosage: "500mg", frequency: "BID", contraindications: [...] }
AllergiesYes, include reaction type (critical for safety)Optionally describe severity{ type: "medication_fact", contraindications: ["Penicillin (rash)", "Sulfa (anaphylaxis)"] }
Treatment historyYes, include outcome (success/failure)Optionally describe complications{ procedure: "PT", outcome: "success", duration: "8 weeks" }

Rule of thumb: Typed fields for anything affecting safety (meds, allergies, contraindications) or clinical decisions (diagnosis status, treatment outcomes). Unstructured for encounter narratives.

Metrics: Impact of Agent Memory

Healthcare organizations using agent memory see:

  • 40% fewer duplicate test orders: AI remembers recent labs, avoids re-ordering
  • 30% faster diagnosis: AI recalls similar cases and applies pattern recognition
  • 25% reduction in adverse events: AI checks medication conflicts before suggesting treatments
  • 15% improvement in patient satisfaction: Patients don't repeat history; care feels continuous
  • 20% reduction in chart review time: Clinician can focus on assessment, not data retrieval

Implementation Checklist

  • Design memory schema with ICD codes, medication structure, and outcome tracking
  • Implement retrieval pipeline (diagnoses → meds/allergies → treatment history → preferences)
  • Add encounter summarization: store key findings, diagnoses, medications after each visit
  • Integrate safety checks: query meds/allergies before suggesting new treatments
  • Test with historical patient records: does AI avoid duplicate tests and recall relevant history?
  • Monitor metrics: duplicate test orders, diagnostic accuracy, chart review time

Next Steps

  • Learn more: Check Schema Design Patterns for HIPAA-safe indexing and field encryption
  • Reference: See Longterm Memory for retention policies and data lifecycle
  • Build: Start with Brain open-source for pilot programs, or try Managed Cloud for HIPAA-compliant production

Related reading

  • ProductionSchema Design Patterns for Agent Memory
  • ProductionLong-Term Memory for Agents
PreviousAgent Memory for Autonomous Trading AgentsNextAgent Memory for Legal Document Analysis

Updates from the lab.

Engineering notes, research drops, occasional product updates. Roughly monthly.

Arc Labs

Cognitive infrastructure for AI agents. Open core in Rust. Composable primitives you own.

GitHubX / TwitterDiscussions

Brain

  • Memory Layer
  • Documentation
  • Pricing
  • Changelog
  • Status

Developers

  • Start here
  • TypeScript SDK
  • Python SDK
  • Rust SDK
  • MCP Server

Company

  • About
  • Careers
  • Blog
  • Security
  • Contact
Encode"Priya lives in Berlin."mem_7f3a · storedRecall"where does Priya live?"→ BerlinSupersede"Priya moved to Lisbon."mem_9c21 ⊃ mem_7f3aBerlin→ LisbonARC LABSARC LABSARC LABS
© 2026 ARC LABS · BANGALOREPrivacyTermsDPAApache 2.0