MedCache: Efficient and Temporally Valid Memory for Longitudinal Clinical Agents
Organizations: University of Michigan, Ann Arbor, MI, USA
Abstract
Longitudinal clinical agents must maintain an evolving patient state from evidence distributed across visits, time points, and specialties. However, how agent memory should be designed for this setting remains unclear. We introduce a benchmark of multi-visit, multi-specialty patient records that evaluates long-context evidence retrieval, cross-time evidence aggregation, and cross-specialty clinical reasoning. Using this benchmark, we systematically study four memory design choices: curation, organization, retrieval, and memory-augmented reasoning. We find that temporal validity is more important than simply retaining more history; specialty-factorized memory reduces context but can hide shared evidence; and multiple agents help when specialists must reason together, not merely when evidence comes from multiple memories. Guided by these findings, we propose MedCache, a hybrid framework that constructs temporally valid patient memory, organizes evidence into overlapping specialty views, routes each query to relevant memories, and adaptively invokes one or multiple specialists. Experiments show that MedCache improves reasoning accuracy and memory efficiency over strong single-agent and multi-agent baselines, while generalizing across model backbones and external datasets.
Figures & tables
| System | Overall [95% CI] | Evid. | C-Time | C-Spec. | In tok. | Calls |
|---|---|---|---|---|---|---|
| Raw context | ||||||
| Long-Context | .705 [.651,.756] | .735 | .667 | .707 | 29.7k | 1.00 |
| Single-agent memory | ||||||
| RAG | .489 [.412,.561] | .294 | .372 | .850 | 14.5k | 1.00 |
| Zep | .731 [.691,.784] | .886 | .870 | .413 | 3.9k | 1.00 |
| MemGPT | .611 [.589,.699] | .727 | .750 | .347 | 4.1k | 1.00 |
| System | C1: Outdated | C2: Missed | C3: Fabricated |
|---|---|---|---|
| Long-Context | 0.549 | 0.413 | 0.038 |
| RAG | 0.536 | 0.440 | 0.025 |
| Mem0 | 0.599 | 0.284 | 0.117 |
| MemGPT | 0.407 | 0.479 | 0.114 |
| Zep | 0.721 | 0.210 | 0.069 |
| MDAgents | 0.797 | 0.166 | 0.037 |
| Mem. | Act. | Output | Overall | Evid. | C-Time | C-Spec. |
|---|---|---|---|---|---|---|
| Centralized | Single | Reader (Zep) | .731 | .886 | .870 | .413 |
| Shared | All | Direct | .920 | .927 | .870 | .950 |
| Shared | All | Coord. | .910 | .915 | .848 | .950 |
| Shared | Routed | Direct (MDAgents) | .862 | .859 | .953 | .800 |
| Shared | Routed | Coord. (ClinicalAgents) | .915 | .941 | .977 | .833 |
| Excl. | Single | Reader | .734 | .720 | .674 | .800 |
| Retrieval policy | Overall | Specialty recall | Fraction of memory read | Context | Route time |
|---|---|---|---|---|---|
| Query BM25 | .680 | .703 | .192 | 3,080 | 0 ms |
| Query+patient BM25 | .688 | .727 | .203 | 3,146 | 0 ms |
| Query dense | .695 | .688 | .155 | 2,432 | 7 ms |
| LLM selection | .945 | 1.000 | .170 | 1,581 | 343 ms |
| Learned gate | .945 | 1.000 | .173 | 1,621 | 7 ms |
| Full memory | .859 | 1.000 | 1.000 | 16,829 | 0 ms |
| Configuration | Overall | Evid | C-Time | C-Spec. |
|---|---|---|---|---|
| Full MedCache | .920 | .939 | .935 | .883 |
| learned gate | .766 | .707 | .674 | .917 |
| validity curation | .840 | .854 | .717 | .917 |
| specialty ownership | .888 | .890 | .891 | .883 |
| Guideline | Prefix reuse | TTFT (s) | ||
|---|---|---|---|---|
| modules | Central | MedCache | Central | MedCache |
| 8 | .888 | .935 | .212 | .164 |
| 16 | .399 | .935 | .472 | .164 |
| 24 | .248 | .926 | .716 | .165 |
| Qwen 3.6-35B-A3B | Mistral-24B | |||
|---|---|---|---|---|
| System | Acc. | In tok. | Acc. | In tok. |
| All active memories | .904 | 11.0k | .920 | 10.7k |
| MedCache | .936 | 8.7k | .920 | 8.4k |
| Selector | Overall | Same | Cross | Owner found | Spec. | Mem. |
|---|---|---|---|---|---|---|
| Requesting specialty only | .433 | .847 | .063 | .472 | 1.00 | .160 |
| BM25 owner selector | .583 | .853 | .342 | .703 | 1.68 | .241 |
| Learned owner gate | .856 | .853 | .858 | 1.000 | 1.53 | .275 |
| Active-specialty union | .853 | .847 | .858 | 1.000 | 4.75 | .605 |
| Central full memory | .842 | .841 | .842 | 1.000 | 10.00 | 1.000 |
| Clean | Distr. | |||||
|---|---|---|---|---|---|---|
| Dataset | System | Acc. | In tok. | Acc. | In tok. | |
| EHRNoteQA | 250 | Scoped full context | .760 | 2.3k | .740 | 2.3k |
| MedCache | .632 | 2.1k | .640 | 2.1k | ||
| LongHealth | 400 | Scoped full context | .825 | 11.9k | .820 | 11.9k |
| MedCache | .440 | 4.3k | .440 | 4.3k | ||
| Quantity | Total | Mean | Median | Min | Max |
| Patients | 91 | – | – | – | – |
| Hospital admissions | 1,152 | 12.7 | 11 | 8 | 39 |
| Record span (years) | – | 5.8 | 5.1 | 0.1 | 13.9 |
| Laboratory measurements | 193,394 | 2,125 | 1,324 | 33 | 8,994 |
| Distinct laboratory concepts | 381 | 88 | 84 | 33 | 171 |
| Benchmark questions | 188 | 2.1 | 2 | 1 | 4 |
| Question type | Count | Required operation |
|---|---|---|
| Evidence retrieval | 82 | Locate one relevant state |
| Cross-time aggregation | 46 | Combine recurring measurements |
| Cross-specialty reasoning | 60 | Combine specialty constraints |
| Total | 188 |
Agent Memory
Agent memory lets AI systems retain, update, and use facts, experiences, and skills across sessions and long-horizon tasks.
See all 192 papers