Agentic AI in research

agentic-ai
research-workflows
medical-imaging
How an AI agent chooses its next step, and how we checked its work in two cardiac MRI experiments.
Author

Marvin Seyfarth

Published

November 27, 2026

What is an AI agent?

Suppose I have a study protocol and a table of twelve synthetic patient records. I want to know how many people meet the inclusion criteria. A language model can explain how to do the calculation. To give me a count that I can check, it needs access to the protocol and the data.

I could write a script that always reads the protocol, filters the table and returns a count. An agent can use the same tools, but it gets to choose what to do next. It might ask to read the protocol first. Once it sees the criteria, it can use them to request a calculation. If a tool reports a missing column, the agent can inspect the table before trying again. Each result informs the next decision. For a calculation I already know how to perform, the script is enough. The room to choose starts to matter when I ask a question like “Which training change should we try next?” (Yao et al. 2023)

A loop links the model's request, execution by a tool and the returned eligibility criteria.
Figure 1: The model requests the protocol. Software reads it and returns the eligibility criteria. These become available to the model when it chooses its next action.

Following one result back to its source

A tool is an operation the model can request, such as reading a file or running an analysis. The model supplies the arguments. The software around it, often called the harness, checks the request, runs the tool and returns the result. That result is the agent’s observation. The harness can also restrict which files the agent can open, record calls and errors, and stop a run when it reaches its time or compute budget.

The instructions, recent actions and observations available when the model makes a decision form its context. For work that spans many experiments, I also want a record that survives the current session. A simple form of memory is an experiment log. An agent can read the previous hypothesis, configuration and score before proposing its next change.

In the synthetic cohort, the protocol specifies age at least 50 years and left ventricular ejection fraction (LVEF) below 50%. We exclude records missing either value. Six of the twelve meet the criteria. If the agent asks for age at least 40 and LVEF below 55%, the same tool runs successfully and returns nine. To check the answer, I compare the arguments with the protocol and rerun the count on the table. This catches an error that a check of the tool’s syntax would miss.

A five-step trace reads the protocol, retrieves the age and LVEF rules, calls the analysis, obtains six eligible records and drafts a report.
Figure 2: The protocol supplies the thresholds, and the analysis returns the count. Keeping both observations lets a reviewer trace the draft back to its two sources.

How does a model learn to use a tool?

Reading the protocol can change what the agent does next even when the language model’s weights stay fixed. The eligibility criteria are now in its context. Training plays a different role. It can make a model more likely to choose a useful action the next time it encounters a similar task.

Toolformer gives a concrete example. Starting with a few demonstrations of each tool, the researchers had a language model propose calls in ordinary text. They kept examples where the returned answer helped predict the words that followed, then trained the model on those examples. A calculator call became worth learning when its result helped complete the passage. In our cohort example, the choice of feedback matters just as much. Rewarding any successful calculation would give the count of nine as much credit as the correct count of six. (Schick et al. 2023)

Can two agents build a cardiac segmentation pipeline?

We gave two coding agents the same cardiac MRI task. Each had to build a pipeline to outline the left ventricular cavity, the left ventricular myocardium and the right ventricular cavity. We used short-axis images from the M&Ms-2 challenge and reorganized and renamed the files to obscure the benchmark identity. The agents had 300 subjects for development. We kept both cardiac phases of each person together in fivefold cross-validation and reserved a further 60 subjects for the final comparison. (Seyfarth, Engelhardt, et al. 2026; M&Ms-2 Challenge Organizers 2021)

From the same brief, the agents made different choices. Agent A tried two- and three-dimensional nnU-Net models and three custom architectures. Agent B developed two nnU-Net configurations and combined their predictions. Both could draw on nnU-Net’s established procedure for adapting segmentation models to a dataset. (Isensee et al. 2021)

Diagrams of two independent model searches, including nnU-Net variants and three custom candidates for Agent A.
Figure 3: The two agents’ choices of models and ensembles. Agent A explored a wider range of architectures, while Agent B compared configurations of nnU-Net.

We compared the predictions with expert contours on 120 held-out volumes, one at end-diastole and one at end-systole for each of the 60 subjects. Dice measures how much two regions overlap. The 95th-percentile Hausdorff distance (HD95) measures how far apart their boundaries are near the upper end of the distance distribution. Together they let us see when an apparently good overlap hides a local boundary error.

Box plots compare three model strategies by structure. Myocardium Dice tends to be lower than left ventricular cavity Dice. HD95 in millimetres is plotted on a logarithmic scale.
Figure 4: Segmentation scores on the same held-out subjects. Higher Dice indicates better overlap. Lower HD95 indicates closer boundaries.

The score distributions broadly overlapped, and the myocardium generally had lower Dice than the left ventricular cavity. I would start a closer review there, by looking at the actual contours on cases where the models disagreed.

Can an agent improve a cine MRI autoencoder?

For a second study, we gave one agent an existing model and asked it to improve how well it reconstructed a cardiac cine sequence. The autoencoder took a 256 × 256 image through 32 time frames, compressed it and tried to reconstruct it. We scored the reconstruction with a fixed validation loss combining absolute pixel error and a perceptual loss. A lower value was better. (Seyfarth, Dar, et al. 2026)

We ran the same agent in three separate workspaces. In each, it read the experiment history, recorded a hypothesis, made an allowed change and trained the model. It kept improvements and reverted other changes. Each workspace had a budget of 30 experiments, with up to three hours per experiment. What changed across the three searches was the guidance and the set of changes the agent could make.

Instructions and permissions Best validation loss
P0. We specified the task and workflow. The agent could tune hyperparameters in the training configuration. 0.0378
P1. We added information about the architecture and data, and allowed changes to training augmentation. 0.0461
P2. We added expert guidance on unstable training, the option to consult literature and full access to the training code. 0.0303
P2 reaches the lowest validation loss at 0.0303, followed by P0 at 0.0378 and P1 at 0.0461.
Figure 5: Validation loss over the three searches. Circles show individual experiments, lines the best loss so far, and stars the best run. The intermediate trajectories were digitized from the original plots and are approximate. The labels give the reported best scores.

P2 found the lowest validation loss. P1 finished above P0 despite its extra context and permissions. Each specification changed several things together, so these searches cannot isolate the effect of expert guidance, code access or augmentation. The agent also used validation loss to decide which changes to keep. Testing the selected configurations on fresh cases would answer a different question about how well those improvements carry over.

What I ask to see after an experiment

For the segmentation task, I want the models’ predictions on the same unseen patients and the contours behind the scores. For the autoencoder, I want the history of changes, the corresponding scores and the saved configuration that produced the best one. Both requests follow from the question we gave the agent. Deciding up front what evidence would answer it makes the work much easier to review.

My research workflow guide shows how I organize these records across projects and use my literature wiki to give agents access to earlier work.

References

Isensee, Fabian, Paul F. Jaeger, Simon A. A. Kohl, Jens Petersen, and Klaus H. Maier-Hein. 2021. “nnU-Net: A Self-Configuring Method for Deep Learning-Based Biomedical Image Segmentation.” Nature Methods 18: 203–11. https://doi.org/10.1038/s41592-020-01008-z.
M&Ms-2 Challenge Organizers. 2021. Multi-Disease, Multi-View and Multi-Center Right Ventricular Segmentation in Cardiac MRI. https://www.ub.edu/mnms-2/.
Schick, Timo, Jane Dwivedi-Yu, Roberto Dessì, et al. 2023. Toolformer: Language Models Can Teach Themselves to Use Tools. https://arxiv.org/abs/2302.04761.
Seyfarth, Marvin, Salman Ul Hassan Dar, and Sandy Engelhardt. 2026. AI-Agent-Driven Autonomous Research Loop for Cardiac MRI Deep Learning Model Optimization. ESC Digital & AI Summit, European Society of Cardiology. https://esc365.escardio.org/presentation/335939.
Seyfarth, Marvin, Sandy Engelhardt, and Salman Ul Hassan Dar. 2026. Replacing the People Who Promised to Replace Clinicians: Autonomous AI-Agents for Cardiac MRI Segmentation. ESC Digital & AI Summit, European Society of Cardiology. https://esc365.escardio.org/presentation/335882.
Yao, Shunyu, Jeffrey Zhao, Dian Yu, et al. 2023. “ReAct: Synergizing Reasoning and Acting in Language Models.” International Conference on Learning Representations. https://arxiv.org/abs/2210.03629.