arXiv:2611.08433cs.CLNov 2026

Manuscript Offprint

arXiv:2611.08433

MedGraph: Maintaining Patient State with Graph Memory for Long-Term Medical Dialogue

Donghua Zhang, Zizheng Wang, Ze Dong, Yiding Feng, Siyu Qian

Abstract

LLM-based medical assistants that follow a patient across visits need a memory that keeps the patient's clinical state correct as it changes. We examine the errors of five memory systems on longitudinal medical dialogue and find three recurring causes: the retrieved evidence gives an outdated state, includes another person's health facts, or lacks a safety fact the answer depends on. We present MedGraph, a graph memory built for these three cases. Construction extracts dated facts from each session, attributes each fact to the person it describes, and links medication, diagnosis, and measurement records into chains that keep earlier states. Retrieval ranks the patient's chains as units, reads each chain at the time the question asks about, and adds the original dialogue text; a patient profile lists every recorded safety fact with every question. On MedMemoryBench, MedGraph has the highest overall accuracy with both a GPT and a Qwen backbone, 10.5 and 10.4 points above the strongest of five baselines, with efficient memory construction and answering in the GPT setting.

1 Introduction

LLM-based healthcare agents increasingly support care across multiple visits, including chronic disease management and medication guidance (Wang et al., 2026). They must track the patient's current medications and reported allergies, since recommending a discontinued medication or overlooking an allergy can lead to unsafe advice. Reliable LLM agents therefore need long-term memory that keeps patient records accurate and up to date across visits.

General-purpose LLM memory systems include retrieval-based methods such as RAG (Lewis et al., 2020), graph-based methods such as GraphRAG (Edge et al., 2024), and agentic approaches such as Mem0 (Chhikara et al., 2025). These systems differ in how they construct memory, including what they retain and how they organize or update it, and how they retrieve evidence for answering. For example, Mem0 extracts and updates conversational facts, while GraphRAG builds an entity-relation graph and community summaries. RAG retrieves similar passages, whereas GraphRAG uses graph-derived summaries. Despite these advances, recent benchmarks report difficulties in reasoning across medical dialogue sessions (Hu et al., 2026; Zhang et al., 2026), and memory accuracy declines as distracting sessions accumulate (Wang et al., 2026).

To examine failures in memory construction and retrieval, we analyze errors from five representative memory systems. This analysis reveals three challenges in longitudinal medical dialogue (Figure 1).

(1) State validity. The same clinical item can have different values or states over time. Some memory systems, such as Mem0, overwrite or discard earlier records when new information arrives (Chhikara et al., 2025). The stored memory may then lack the records needed to answer historical questions. Other systems, such as MemOS, can retain a relevant record without marking it as current in the retrieved evidence. In 24 of the 150 sampled failures, the evidence contained only an outdated state or left the current state unclear. A medical memory must preserve past states and identify which state applies at the relevant time.

(2) Subject attribution. Longitudinal medical dialogue may contain health information about multiple subjects. Without clear attribution, clinical information about a subject other than the patient may be mistaken for the patient's own. In 108 of the sampled failures, the evidence contained such information. Each clinical fact therefore needs an explicit link to the subject it describes.

(3) Safety prioritization. Safety information can constrain decisions across later visits. For example, a documented allergy may affect a subse-

∗^{*}Equal contribution.

†^{\dagger}Corresponding author: donghua@umich.edu

Figure

Figure 1: Three challenges in longitudinal medical memory. (a) We inspect 150 wrong answers from five memory systems, 30 per system, and the evidence supplied to the answering model. Each square represents one wrong answer, with colors indicating the observed challenges. Split squares indicate two challenges; gray squares indicate failures outside these categories. Categories overlap, so their counts do not sum to 150. (b) LightMem misses the patient's September 10 walking-distance measurement, leading to an answer based on an older reading. (c) MemOS retrieves the father's medication when the patient asks about their own symptoms. (d) REMem omits a recorded co-trimoxazole allergy when answering a later question about antibiotics.

quent prescription. In 18 of the sampled failures, we found that the evidence omitted a safety fact needed for the answer. The memory must therefore keep safety-critical information available for later clinical decisions.

Motivated by these findings, we propose MedGraph, a multi-layer memory with raw dialogues (L1), a clinical fact graph (L2), and a patient profile (L3). During construction, we extract each session into typed fact nodes that record the subject and event date while preserving values and units. Supersedes edges connect successive records of the same clinical item, including medication changes and repeated measurements. Causal edges link related facts within a session. At retrieval time, we rank the patient's chains as units, along with facts outside chains. Every answer also receives the patient profile so that important details, including safety constraints, remain available to the answering model.

We evaluate MedGraph on MedMemoryBench against five existing memory systems using two backbones. MedGraph achieves the highest overall accuracy with both backbones, exceeding the strongest baseline by 10.5 percentage points with GPT and 10.4 with Qwen.

Our contributions are as follows:

  • We analyze failures in longitudinal medical dialogue and formulate three memory requirements: state validity, subject attribution, and safety prioritization.

  • We introduce MedGraph, a multi-layer memory that links subject-attributed clinical facts into

dated chains. Its patient profile accompanies every answer.

  • We show consistent accuracy gains across two backbones, with efficient memory construction and answering in the GPT setting.