> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clinia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Memory

> How Clinia agents remember and learn over time

# Agent Memory

An agent's ability to **remember** is what makes it useful in complex healthcare workflows. Without memory, an agent would treat every conversation as a blank slate, repeating questions and forgetting critical details, its *world* being ultimately bound by by the chat history. Clinia addresses this by providing persistent, structured memory for each agent.

## Why Persistent Memory Matters

Stateful systems retain information across interactions. For agents, this means that memories of past user interactions, clinical context and decisions remain available to guide future responses.

### Benefits of Persistent Memory

<CardGroup cols={3}>
  <Card title="Personalization" icon="user-gear">
    By recalling prior conversations and user preferences, agents can tailor their responses to individual clinicians and patients.
  </Card>

  <Card title="Efficiency" icon="clock">
    Remembering what has already been captured (e.g., family history) prevents redundant questions and saves time.
  </Card>

  <Card title="Accuracy" icon="bullseye">
    Combining long‑term memory with real‑time retrieval improves the agent's ability to suggest appropriate billing codes or referral options.
  </Card>
</CardGroup>

## Core Memory Structure

Clinia divides agent memory into several **memory blocks**:

<Tabs>
  <Tab title="User Memory">
    ### User Memory Block

    The user memory block stores information about the **human users** who interact with the agent. It captures:

    * 👤 **User preferences and roles** (e.g., physician, nurse)
    * 📋 **Historical interaction details**
    * 🎯 **Personalization data**

    <Note>
      For example, if a user previously requested cardiology guidelines, the agent can prioritize cardiology resources in future interactions.
    </Note>
  </Tab>

  <Tab title="Patient Memory">
    ### Patient Memory Block

    The patient memory block contains the **clinical context** of the current interaction. It holds:

    * 🩺 **Patient's presenting complaints**
    * 💊 **Active medications**
    * 🧪 **Recent lab results**
    * 📊 **Retrieved FHIR/OMOP data**

    <Info>
      This memory block is often populated through retrieval tools that query FHIR or OMOP data sources, and it is kept up to date as new information is discovered. Having clinical context readily available allows the agent to make safer and more informed recommendations.
    </Info>
  </Tab>

  <Tab title="Clinician Memory">
    ### Clinician Memory Block

    The clinician memory block defines the **agent's clinical identity and behaviour**. It includes:

    * 🏥 **Medical specialty focus**
    * 🛡️ **Safety guardrails and compliance rules**
    * 🗣️ **Domain-specific vocabulary and communication style**
    * 📋 **Predefined templates for different specialties**

    <Tip>
      Loading a clinician memory block transforms a generic agent into a specialized cardiology, dermatology or general practice assistant.
    </Tip>
  </Tab>
</Tabs>

## Long-term vs Short-term Memory

Clinia agents maintain both **long‑term** and **short‑term** memory:

<Tabs>
  <Tab title="Short-term Memory">
    ### Short-term (Conversation) Memory

    * 💬 **Retains recent dialogue** between user and agent
    * 🧠 **Stored within the agent's context window**
    * ⚡ **Informs immediate replies**
    * ⏳ **Eventually "forgotten" as conversation progresses**

    <Warning>
      Because context windows are finite, short‑term memory can eventually be "forgotten" as the conversation progresses.
    </Warning>
  </Tab>

  <Tab title="Long-term Memory">
    ### Long-term Memory

    * 🔄 **Persists across conversations and sessions**
    * 💾 **Saved to Clinia's backend for recall at any time**
    * 🏥 **Includes EHR data from FHIR/OMOP ingestion**
    * 👤 **Stores user preferences and core clinical facts**

    <Info>
      Memory management is handled on the server, meaning client applications do not need to serialize or reload state. The [What is an Agent?](/explanation/agents/intro) page explains how Clinia's stateful architecture differs from stateless chat APIs.
    </Info>
  </Tab>
</Tabs>

## Sharing and Collaboration

Because agents are deployed as services (see [Agents as a Service](/explanation/agents/service)), multiple agents can share core memory.

<Card title="Example: Collaborative Workflow" icon="handshake">
  A background agent responsible for filling out referral forms can access the same clinical memory as the primary agent interacting with the clinician. This collaboration improves consistency across tasks and reduces duplication.
</Card>

## Using Memory Effectively

When designing agents, it is important to:

<Steps>
  <Step title="Define Clear Memory Schemas">
    Decide which data belongs in user, clinical or persona memory. Structured schemas help the agent retrieve relevant information quickly.
  </Step>

  <Step title="Respect Privacy">
    Persisted memory must comply with privacy regulations. Clinia's platform provides encryption and access controls to protect sensitive data.
  </Step>

  <Step title="Combine Memory with Retrieval">
    Memory alone is not enough; agents should supplement long‑term knowledge with up‑to‑date information from FHIR/OMOP sources using retrieval tools. The [tools and data integration](/explanation/agents/tools) page describes how to ingest data and connect tools.
  </Step>
</Steps>

***

<Tip>
  By carefully structuring memory and leveraging Clinia's built‑in persistence, developers can create agents that **learn over time**, provide **consistent experiences** and **adapt to the needs** of healthcare professionals.
</Tip>
