Manuscript Offprint

arXiv:2609.15859

LongAgent: History-Guided Agentic Search for Longitudinal Outcome Prediction

Siyao Wang, Florian Guitton, Shuojie Fu, Guanyu Tao, Kai Sun, Wenjia Bai

Siyao Wang 1,2∗^{1,2*}, Florian Guitton 1^{1}, Shuojie Fu 1^{1}, Guanyu Tao 1^{1}, Kai Sun 1^{1}, and Wenjia Bai 1,2,3^{1,2,3}

1^{1} Data Science Institute, Imperial College London, London, UK

2^{2} Department of Computing, Imperial College London, London, UK

3^{3} Department of Brain Sciences, Imperial College London, London, UK

s.wang18@imperial.ac.uk

Abstract. Extracting informative representations from longitudinal data that can predict future outcomes remains a critical challenge in medicine. Medical datasets are inherently heterogeneous, consisting of a large number of variables collected from different sources, sampled with different temporal spacings, and representing different aspects of human health status. This requires identifying those variables with predictive value, processing longitudinal information, and integrating multiple variables for outcome prediction. Here, we propose a novel agent-based approach, LongAgent, that can autonomously search over combinations of variable sets, temporal windows and longitudinal aggregation functions, and identify candidates with promising predictive performance. LongAgent utilises a history memory of previous searches and numerical evidence to guide subsequent exploration. On synthetic data, LongAgent achieves a mean prediction RMSE of 1.7376 and improves over the strongest non-agent baseline by 0.0151 (95% CI: [0.0045, 0.0260]; p = 0.0273). On a real clinical dataset, it performs comparably to the best baseline.

Keywords: Agentic search · Predictive modelling · Longitudinal data · Longitudinal outcome prediction

1 Introduction

In medical research, longitudinal outcome prediction involves collecting multimodal measurements of an individual, monitoring their longitudinal changes, and developing a predictive model that can learn multimodal features from the data for predicting future outcomes [2]. Typically, features, also known as predictors, are extracted by selecting a subset of recorded variables, followed by choosing an empirical time window and an aggregation function that can be applied to longitudinal measurements. Given the complexity of clinical longitudinal datasets and the exploratory nature of medical research, feature extraction is often performed in a hand-crafted manner and is time-consuming.

∗^{*} Corresponding author.

S. Wang et al.

Repeated monitoring of outcomes adds another layer of complexity. In longitudinal studies, the outcome may be recorded at multiple time points for each participant. Predictors must therefore be constructed only from measurements preceding each observed outcome to avoid information leakage [2]. However, the appropriate duration of this preceding time window is often unknown. Dunn et al. found that the performance of predictive models using wearable device measurements varied with the monitoring time window and its proximity to the outcome date [6]. FIDDLE and flexible-window electronic health record (EHR) methods explore different ways to define the time window [8,18]. Based on the time window, different aggregation functions have been explored to integrate longitudinal measurements to form predictive features [3,7,13].

Recently, AI agents, implemented as large language models (LLMs), have demonstrated great potential to either perform predefined workflows or discover new knowledge [4,12,19]. For longitudinal medical data analysis, PHIA has been proposed, which combines code generation and information retrieval to answer questions about wearable device data [15]. FeatEHR-LLM utilises an agent to generate executable feature extraction code for analysing irregular time series EHR data [10]. CoDaS coordinates hypothesis generation, analysis, grounding, and validation for discovering wearable device biomarkers [11]. LLM-FE proposes validation-guided evolution to search over a space of feature transformation programs to process tabular data [1].

These studies demonstrate the potential of LLM agents but primarily focus on generating code for feature transformation and data analysis. The proposed method, LongAgent, focuses on search for longitudinal outcome predictors. It uses accumulated evidence to guide the search for a combination of variable subset, time window and aggregation function that leads to predictive features for future outcomes. Our main contributions are:

  1. We formulate the discovery of predictive features as a budgeted search problem, over a search space of variable subsets, time windows, and aggregation functions.

  2. We introduce a history-guided search agent that combines search status, candidate history, coverage summary, and transition evidence, and uses a two-stage decision process to decide the next move.

  3. We evaluate LongAgent against three non-agent search policies on a large number of synthetic datasets constructed with diverse settings and a real longitudinal cohort, and demonstrate LongAgent outperforms or on par with other search policies.

References (18)

  • LLM-FE: Automated feature engineering for tabular data with LLMs as evolutionary optimizers
  • Machine and deep learning for longitudinal biomedical data: A review of methods and applications
  • Time series FeatuRe extraction on basis of scalable hypothesis tests (tsfresh - a Python package)
  • The role of agentic artificial intelligence in healthcare: a scoping review
  • Wearable sensors enable personalized predictions of clinical laboratory measurements
  • hctsa: A computational framework for automated time-series phenotyping using massive feature extraction
  • Flexible-window predictions on electronic health records
  • An introduction to variable and feature selection
  • FeatEHR-LLM: Leveraging large language models for feature engineering in electronic health records (opens arXiv in a new tab)
  • CoDaS: AI co-data-scientist for biomarker discovery via wearable sensors (opens arXiv in a new tab)
  • Towards end-to-end automation of AI research
  • catch22: CAnonical time-series CHaracteristics
  • IDEA-FAST clinical study protocol: Identifying digital end-points of fatigue, sleep quality and daytime sleepiness in N = 2000
  • Transforming wearable data into personal health insights using large language model agents
  • gpt-oss-120b & gpt-oss-20b Model Card
  • A review of feature selection techniques in bioinformatics
  • Democratizing EHR analyses with FIDDLE: A flexible data-driven preprocessing pipeline for structured clinical data
  • 3DMedAgent: Unified perception-to-understanding for 3d medical analysis