An AI Agent for Automated Causal Inference in Epidemiology

Haochen Liu, Ke Shi, Ang Li, Xinyu Li, Jiali Chu, Yingqian Xue, Sihui Cen, Yuyi Wang, Tianxiao ZhangmedRxiv 2026 · DOI

This paper introduces EpiCausalX Agent, an AI-powered system designed to automate the complex, manual workflow of epidemiological causal inference. By combining the reasoning capabilities of the DeepSeek V3.2 large language model (LLM) with specialized tools for literature retrieval and graph theory, the agent allows researchers to move from a natural language query to a fully realized, evidence-based Directed Acyclic Graph (DAG) in minutes.

TL;DR

EpiCausalX is an autonomous AI agent that automates the end-to-end process of epidemiological causal inference—from cross-database literature synthesis to the generation of Directed Acyclic Graphs (DAGs). It lowers the expertise barrier for researchers by integrating Hill’s criteria and graph theory into a verifiable, "think-act-observe" agentic workflow.

What Problem Does This Paper Address?

Causal inference—determining if "A causes B"—is the core mission of epidemiology, but the traditional process is fraught with bottlenecks. Currently, researchers must manually search multiple databases (like PubMed), deduplicate results, identify potential confounders (variables that distort the relationship), and mediators (variables on the causal path), and then manually draw DAGs to visualize these relationships.

This manual process is not only time-consuming but also highly subjective and prone to "expert bias." Furthermore, while general-purpose LLMs like GPT-4 are helpful, they often lack the domain-specific rigor required for medical research and are prone to hallucinations. The authors sought to create a specialized tool that bridges the gap between high-level AI reasoning and rigorous epidemiological standards.

Methods

The authors built EpiCausalX using the LangChain 1.0 framework and the ReAct (Reasoning + Acting) paradigm. This allows the agent to follow a cyclic "think-act-observe" loop: it analyzes a user's query, decides which tool to use, observes the results, and iterates until the task is complete.

Key technical components include:

  • The Brain: DeepSeek V3.2 LLM, configured with a "sliding window" memory to maintain context over long conversations without performance degradation.
  • Tool Layer: Eight specialized tools, including a parallel search engine for seven academic databases and an automated DAG drawer using NetworkX and Matplotlib.
  • Causal Logic: Instead of just "guessing" relationships, the agent uses NLP to extract evidence from abstracts and evaluates associations based on Hill’s Criteria (e.g., temporal sequence, dose-response relationship, and biological plausibility).
  • Architecture: A four-layered design (Agent, Tool, Storage, and Utility) ensures that data is persistent (PostgreSQL) and files (like DAG images) are stored securely (S3-compatible storage).

Datasets

The agent does not rely on a single static training set. Instead, it performs real-time retrieval from seven major academic databases:

  1. PubMed
  2. Web of Science
  3. BioRxiv
  4. MedRxiv
  5. DOAJ
  6. OpenAlex
  7. Semantic Scholar

For evaluation, the authors conducted a usability test with 12 participants (6 non-technical clinical epidemiologists and 6 researchers with basic AI experience) and validated the agent's logic through three real-world case studies.

Key Insights and Ideas

  • Agentic Workflow vs. Chatbot: The core "aha moment" is that the system doesn't just answer questions; it executes research. It can autonomously decide to perform a general search, then a targeted search for mechanisms, then identify confounders based on graph topology.
  • Automated Confounder Identification: The agent identifies variable types (exposure, outcome, mediator, confounder) based on the direction of edges in the graph. It can then determine the Minimal Sufficient Adjustment Set (MSAS)—the specific variables a researcher must control for to get an unbiased result.
  • Verifiability: Unlike black-box AI, EpiCausalX provides traceable evidence, including PMIDs, journal names, and specific snippets from literature to support every edge it draws in a DAG.

Key Results

  • Full Automation: The agent successfully automated the entire pipeline from query to visualization.
  • High Usability: In testing, all users (including those with no technical AI background) were able to initiate complex tasks within an average of just two rounds of dialogue.
  • Case Study Validation:
    • PM2.5 & Asthma: The agent correctly identified pulmonary inflammation as a mediator and suggested socioeconomic status and genetic factors as key confounders.
  • Whole Grains & T2DM: It synthesized evidence from 16 cohort studies, confirming a 32% risk reduction for Type 2 Diabetes and identifying insulin sensitivity as a core mediating mechanism.
  • TSH & CKD: It identified a gender-specific causal association where elevated TSH levels increased kidney disease risk in men but not women.

Limitations and Future Work

The authors acknowledge several areas for growth:

  • Domain Scope: Currently focused primarily on epidemiology; future versions could expand into broader medical domains.
  • Performance: The retrieval algorithms need further optimization to reduce latency during real-time searches.
  • Multimodality: Future iterations aim to integrate diverse data types, such as time-series data and medical images, into the causal reasoning process.
  • Open Source: The team plans to release the agent as an open-source project to encourage community-driven optimization.

Summary updated

Abstract

Abstract Objective To address the inefficiency, subjectivity, and high expertise barrier of traditional epidemiological causal inference, this study designed, developed, and validated an AI-powered agent (EpiCausalX Agent) to automate the end-to-end workflow. It integrates cross-database literature retrieval, intelligent causal reasoning, and Directed Acyclic Graph (DAG) visualization to provide a reliable, accessible tool for researchers. Materials and Methods Built on the LangChain 1.0 framework with a layered design (Agent/Tool/Storage/Utility Layers), the agent uses the DeepSeek V3.2 LLM and ReAct paradigm for dynamic task orchestration. Four specialized tools were integrated including multi-database retrieval with 7 databases, causal inference based on Hill’s criteria and DAG logic, automated DAG drawing using NetworkX and Matplotlib, and clinical standard query. Performance was validated via unit tests, workflow verification, and usability testing. Results The agent achieved full-process automation. It efficiently retrieves and synthesizes literature, automatically identifies confounders and mediators, and generates standardized interactive DAGs. It produces evidence-based, traceable conclusions aligned with established epidemiological knowledge. Its user-friendly natural language interface enables seamless use by non-technical researchers who complete task initiation quickly without operational confusion. The agent is publicly available on WeChat Mini Program for easy access. Conclusion EpiCausalX Agent advances intelligent, automated epidemiological research. By integrating domain expertise with AI agent technology, it overcomes limitations of manual methods and general LLMs to provide a specialized, verifiable, efficient solution. It has broad applications in observational research, clinical study design, and education to enhance productivity and lower barriers to rigorous causal analysis.
BibTeX
@misc{liu2026ai,
  author = {Haochen Liu and Ke Shi and Ang Li and Xinyu Li and Jiali Chu and Yingqian Xue and Sihui Cen and Yuyi Wang and Tianxiao Zhang},
  title = {{An AI Agent for Automated Causal Inference in Epidemiology}},
  year = {2026},
  doi = {10.64898/2026.02.06.26345723},
  howpublished = {medRxiv},
}
Figure