MedAgentGym: A Scalable Agentic Training Environment for Code-Centric Reasoning in Biomedical Data Science
Ran Xu, Yuchen Zhuang, Yishan Zhong, Yue Yu, Zifeng Wang, Xiangru Tang, Hang Wu, May Dongmei Wang, Peifeng Ruan, Donghan Yang, Tao Wang, Guanghua Xiao, Xin Liu, Carl Yang, Yang Xie, Wenqi Shi
International Conference on Learning Representations 2026 · Oral
Overview
This talk introduces MedAgentGym, a novel, scalable, and interactive training environment specifically engineered to enhance the coding-based biomedical reasoning capabilities of large language models (LLMs). Developed by a collaborative team from Georgia Tech, Emory University, Yale, and UT Southwestern Medical Center, MedAgentGym addresses critical limitations in existing medical AI benchmarks, which predominantly focus on static, closed-form knowledge retrieval without incorporating the crucial dimension of computational reasoning through code. The project is fully open-sourced, providing documentation, code, models, and data to the broader research community.

Key moments
- 0:00 Introduction: MedAgentGym for code-centric biomedical reasoning
- 1:10 Limitations of existing medical reasoning benchmarks and motivation
- 2:00 MedAgentGym design: verifiable, code-based tasks, scale
- 3:00 Initial findings: SOTA LLM performance and task difficulty
- 4:10 Interactive, Docker-based training environment for agents
- 5:15 Training strategies: SFT, RL, and reward modeling
- 6:30 Crucial role of debugging and environment interaction
- 7:00 Demonstrated generalization to out-of-distribution tasks
MedAgentGym: A Scalable Agentic Training Environment for Code-Centric Reasoning in Biomedical Data Science
Speakers: Ran Xu, Yuchen Zhuang, Yishan Zhong, Yue Yu, Zifeng Wang, Xiangru Tang, Hang Wu, May Dongmei Wang, Peifeng Ruan, Donghan Yang, Tao Wang, Guanghua Xiao, Xin Liu, Carl Yang, Yang Xie, Wenqi Shi
Conference: ICLR 2026
YouTube: https://slideslive.com/39062129
Overview
This talk introduces MedAgentGym, a novel, scalable, and interactive training environment specifically engineered to enhance the coding-based biomedical reasoning capabilities of large language models (LLMs). Developed by a collaborative team from Georgia Tech, Emory University, Yale, and UT Southwestern Medical Center, MedAgentGym addresses critical limitations in existing medical AI benchmarks, which predominantly focus on static, closed-form knowledge retrieval without incorporating the crucial dimension of computational reasoning through code. The project is fully open-sourced, providing documentation, code, models, and data to the broader research community.
The motivation behind MedAgentGym stems from the growing recognition that code generation significantly boosts reasoning across various domains, including the complex field of medicine. While current medical LLMs often struggle with tasks requiring dynamic interaction, logical deduction, and computational execution, MedAgentGym aims to bridge this gap by providing an environment where LLM agents can learn to write and execute code (e.g., SQL queries for Electronic Health Records, bioinformatics scripts) to solve complex biomedical problems. This approach is seen as a vital step towards achieving more generalized artificial intelligence (AGI) in specialized domains like healthcare.
By focusing on verifiable medical reasoning tasks that directly benefit from code-based solutions, MedAgentGym offers a robust platform for training and evaluating LLM agents. It moves beyond simple question-answering to foster true problem-solving abilities, enabling models to interact with structured and unstructured biomedical data in a dynamic, iterative manner. The environment's design, including its Dockerized setup and integration with distributed computing frameworks, ensures scalability and ease of use, paving the way for advanced agentic AI development in medical data science.
Background
▶ Watch: Introduction: MedAgentGym for code-centric biomedical reasoning (0:00)
The landscape of medical artificial intelligence has seen rapid advancements, particularly with the advent of large language models. However, a persistent challenge has been the effective application of these models to complex, real-world biomedical reasoning tasks. Traditionally, medical AI benchmarks have largely centered on closed-form knowledge QA (Question Answering) and knowledge retrieval tasks. These benchmarks, while valuable for assessing factual recall, often fall short in evaluating an LLM's ability to perform computational reasoning, interact with dynamic environments, or generalize across diverse problem types.
A fundamental limitation of these existing paradigms is their reliance on LLMs to memorize vast amounts of medical knowledge. As research progresses, there's a growing consensus that true intelligence, especially in intricate domains like medicine, requires more than just memorization. It demands robust reasoning capabilities, the ability to utilize external tools (such as search engines or dedicated databases), and critically, the capacity to generate and execute code. Code-based reasoning offers a powerful avenue for transforming abstract medical problems into verifiable, computational steps. For instance, tasks like querying structured EHR data with SQL, performing bioinformatics analyses, or deriving insights from complex biological equations can be precisely addressed through code.
The speaker highlights that even rule-based or equation-based reasoning benefits immensely from code. Early tests demonstrated a "considerable jump" in performance when LLMs were empowered to write and execute code, contrasting sharply with purely language-based reasoning. Despite this clear advantage, existing medical benchmarks for LLMs predominantly lack any coding component. They are often smaller in scale, provide static evaluation scenarios, and do not encourage the interactive, iterative problem-solving approach that is inherent to coding. This gap motivated the creation of MedAgentGym: an environment specifically designed to incorporate a multitude of coding-based tasks, thereby pushing medical agents towards more sophisticated, AGI-like reasoning capabilities. The goal is to move beyond models that merely "memorize facts" to models that can "use a dedicated search tool" or "write a code" to solve problems.
Key Findings
▶ Watch: MedAgentGym design: verifiable, code-based tasks, scale (2:00)
The development and initial benchmarking of MedAgentGym revealed several crucial insights into the performance and capabilities required for code-centric medical reasoning in LLMs:
- Commercial LLMs Lead: At the time of publication, commercial models, particularly those from the GPT-4 family, consistently demonstrated strong performance across a diverse range of tasks within MedAgentGym. This suggests their robust general reasoning and coding abilities translate effectively to the biomedical domain.
- Structured Data is Easier: Tasks involving structured EHR queries, such as writing SQL to extract specific patient data from a database schema, were found to be relatively easier for LLMs. The structured nature of the data and the well-defined query language provide clear constraints and pathways for reasoning.
- Open-Ended Bioinformatics Remains Challenging: Conversely, more open-ended tasks in DNA bioinformatics and RNA transcription proved significantly more challenging. A hypothesized reason for this difficulty is the lower verifiability of these tasks, making it harder for models to learn and self-correct without clear, immediate feedback.
- Enhanced Reasoning Improves Performance: Models explicitly designed for enhanced reasoning, such as Qwen-32B-QWQ and DeepSeek-R1, exhibited better performance. The ability to engage in longer reasoning chains during test-time computation directly correlated with improved outcomes in code generation and open-ended medical reasoning.
- Need for Joint Medical and Coding Training: While specialized coding models and specialized medical AI models exist, they often lag when confronted with tasks requiring both medical domain knowledge and coding proficiency. This highlights a significant opportunity and a clear need for joint training paradigms that integrate both aspects, treating coding for medical LLMs as a unified, beneficial task.
- Crucial Role of Interaction and Debugging: Experimental results demonstrated a "significant jump" in performance when models were allowed to interact with the environment and utilize debugging capabilities. Without this interactive loop, there was a notable drop in success rate, underscoring the importance of dynamic feedback mechanisms.
- "Expert Loop" Failure Mode: A consistent failure mode observed was that the model or agent would frequently get "stuck in the expert loop" without knowing how to proceed or what actions to take next. This indicates a need for more sophisticated interaction strategies and error recovery mechanisms within agentic LLMs.
- Generalization to Out-of-Distribution Tasks: Despite differences between training and test distributions (e.g., significant cosine similarity differences), models trained within MedAgentGym were able to generalize well to out-of-distribution benchmark tasks, showcasing the robustness of the training environment.
Technical Deep Dive
▶ Watch: Interactive, Docker-based training environment for agents (4:10)
MedAgentGym is designed as an interactive, scalable, and secure training environment for large language model (LLM) agents focused on code-centric biomedical reasoning. Unlike traditional static benchmarks, its core innovation lies in fostering dynamic interaction and verifiable code execution.
At its heart, MedAgentGym focuses on verifiable medical reasoning tasks that inherently benefit from code-based solutions. Examples include writing SQL queries to compute patient revisits from a database or generating scripts for bioinformatics analysis. The environment incorporates a comprehensive set of 72 coding task instances spanning across 129 diverse categories. These tasks draw from real-world biomedical datasets, including MIMIC-III and eICU (dedicated to ICU patient visits), EHRShot (for fact extraction and equation writing), and BioCoder (for scientific writing and code generation). This broad coverage ensures a rich and varied learning experience for LLM agents.
A critical design choice for MedAgentGym is its Dockerized environment. Each task instance is pre-installed within a dedicated Docker image. This approach offers several key advantages:
- Ease of Implementation: Practitioners can readily set up and run experiments without extensive pre-configuration, as all necessary dependencies are encapsulated.
- Security and Isolation: The Docker image securely stores data and isolates the LLM agent's interactions. This ensures that the agent operates within a controlled environment, preventing unintended side effects and maintaining data integrity.
- Reproducibility: The containerized nature guarantees consistent environments across different runs and users, enhancing the reproducibility of research.
The interaction between the LLM agent and the environment follows a continuous scaffolding-plus-interaction loop. Within this loop, an agent initiates an action, receives a reward based on the outcome of that action, and then observes the environment's new state. This iterative process allows the agent to learn from its actions and refine its code generation and execution strategies. The system is currently designed to synchronize with open-source Reinforcement Learning (RL) models for training, enabling agents to learn optimal policies through trial and error.
To support scalable and diverse agent training, MedAgentGym natively integrates with distributed computing frameworks like Ray and Joblib. This allows for the efficient rollout of multiple trajectories and the collection of extensive interaction data. This collected data, including expert scientific trajectories (e.g., 6,000 simple trajectories and 60,000 expert trajectories), forms the basis for various agent training methodologies.
The training pipeline leverages several advanced techniques:
- Supervised Fine-Tuning (SFT): Initial model capabilities are significantly boosted through SFT. For instance, Qwen-3 models (specifically Qwen-15-7B and 14B instruct versions) showed a "huge jump" in performance across different tasks after SFT, demonstrating the effectiveness of supervised learning on expert demonstrations.
- Offline Preference Optimization (PO) and GRPO: To further enhance model performance, advanced RL techniques like offline preference optimization or GRPO algorithms are applied. These methods allow models to learn from human or automated preferences over generated solutions, pushing them towards higher-quality outcomes.
- Outcome Supervised Reward Model: A crucial component of the training system is an outcome supervised reward model. This model is trained on the collected expert trajectories to predict whether a generated solution or trajectory constitutes a "good performance" or not. This reward signal is vital for guiding RL agents and evaluating their progress.
- Rejection Sampling: The outcome supervised reward model is also employed for rejection sampling. By using the verifier to score rollouts, the system can filter out suboptimal solutions or guide fine-tuning processes. This technique was shown to bring an additional 3% to 5% gain on top of existing experiments, even with light SFT.
Furthermore, MedAgentGym specifically structures its data into two parts: a training and internal validation set and an external validation set. This allows researchers to rigorously evaluate the generalization capabilities of different LLM agents across diverse domains and unseen tasks, ensuring that models learn robust and transferable skills rather than merely memorizing training examples.
Experimental Setup & Results
▶ Watch: Training strategies: SFT, RL, and reward modeling (5:15)
The experimental evaluation of MedAgentGym involved benchmarking state-of-the-art LLMs and developing novel training methodologies within its interactive environment. The core of the experimental setup revolved around the MedAgentGym benchmark itself, which comprises 72 coding task instances across 129 diverse categories. These tasks are derived from established biomedical datasets such as MIMIC-III, eICU, EHRShot, and BioCoder, ensuring a realistic and challenging evaluation landscape. The dataset is strategically partitioned into a training/internal validation set and an external validation set to rigorously assess generalization.
Various LLM agents were tested:
- Commercial LLMs: The GPT-4 families were benchmarked as leading commercial models, consistently showing strong performance.
- Reasoning-Enhanced Models: Specific models like Qwen-32B-QWQ and DeepSeek-R1 were evaluated for their enhanced reasoning capabilities, demonstrating superior performance in tasks requiring longer computational thought.
- Specialized Models: The talk noted that specialized coding models and medical AI models, when evaluated in isolation, did not perform as well on the combined medical coding tasks, reinforcing the need for integrated training.
The primary metric for evaluation was success rate, indicating the proportion of tasks for which the agent could generate and execute correct code to achieve the desired outcome.
Key experimental results and headline numbers include:
- Impact of Supervised Fine-Tuning (SFT): Training Qwen-3 models (specifically the Qwen-15-7B and 14B instruct versions) with SFT on expert trajectories resulted in a "huge jump" in capability across different tasks. This highlights the effectiveness of initial supervised learning from high-quality demonstrations.
- Benefits of Reinforcement Learning: Further pushing model performance was achieved by incorporating offline preference optimization or the GRPO algorithm, indicating that learning from preferences or rewards can refine and enhance SFT-trained agents.
- Scaling with Training Data: Experiments with the outcome-supervised reward model demonstrated a clear scaling relationship: as the number of training data points (expert trajectories) increased, the success rate of the post-trained models significantly improved. This was visualized by a figure showing success rate versus the number of training data.
- Agent Rollouts and Success Rate: Similarly, increasing the number of agent rollouts during inference time also led to a significant jump in success rate, particularly in the initial phases, before showing diminishing returns. This suggests that more exploration and interaction with the environment can lead to better performance.
- Effectiveness of Rejection Sampling: Using the outcome-supervised reward model to perform simple rejection sampling yielded additional gains. This verifier, capable of scoring up to 16 rollouts, could bring an additional 3% to 5% improvement in performance, even when combined with light SFT.
- Cruciality of Debugging and Interaction: A critical ablation study revealed a "significant jump" in performance when models possessed debugging or interaction capabilities with the environment (represented by blue lines in a graph). Conversely, a "significant drop" was observed without these capabilities (brownish lines), both in general and in the medical agent domain. This unequivocally demonstrated that dynamic interaction and debugging are vital for success.
- Failure Mode Analysis: Approximately half the time, the model or agent would get "stuck in the expert loop" without knowing how to proceed. This consistent failure mode underscores the challenges of autonomous agentic reasoning and the need for more robust error handling and self-correction mechanisms.
- Out-of-Distribution Generalization: The training methodology within MedAgentGym enabled models to generalize well to out-of-distribution benchmark tasks. This was despite a "huge cosine similarity difference" between the training and test distributions, validating the environment's ability to foster transferable skills.
These results collectively underscore the potential of MedAgentGym as a robust platform for developing and evaluating LLM agents capable of complex, code-centric medical reasoning, while also highlighting key areas for future research, particularly in enhancing interactive debugging and robust error recovery.
Practical Implications
▶ Watch: Demonstrated generalization to out-of-distribution tasks (7:00)
MedAgentGym presents profound practical implications for various stakeholders in the AI/ML and healthcare domains, shifting the paradigm from static knowledge retrieval to dynamic, code-centric reasoning in medical AI.
For Practitioners and Model Builders:
- Shift to Active Reasoning: The core implication is the necessity for LLMs to transcend passive knowledge recall and engage in active, computational reasoning. Practitioners developing medical AI models must now consider how their agents can generate, execute, and debug code to solve problems, rather than merely answering questions based on memorized facts.
- Interactive Environments as Training Grounds: MedAgentGym demonstrates the immense value of interactive training environments. Model builders should prioritize developing and utilizing such dynamic platforms where agents can learn through iterative interaction, receive feedback, and refine their strategies, mirroring real-world problem-solving.
- Joint Training for Holistic Capabilities: The finding that specialized coding and medical models lag when combined tasks are presented suggests a strong need for integrated training. Model builders should explore methodologies that jointly optimize for both robust coding abilities and deep medical domain knowledge, fostering a more holistic AI agent.
- Open-Source Acceleration: The open-sourced nature of MedAgentGym (code, documentation, models, data) provides a significant accelerator for research and development. Practitioners can readily adopt, adapt, and build upon this environment, reducing setup overhead and fostering collaborative innovation in medical agentic AI.
- Debugging is Key: The clear evidence that debugging capabilities are crucial means that future agent designs must incorporate mechanisms for self-correction, error identification, and iterative refinement of generated code within the environment.
For Infrastructure Teams and Deployers:
- Dockerized Deployment for Ease and Security: The Dockerized environment simplifies deployment significantly. Infrastructure teams can leverage this containerized approach for consistent, secure, and isolated execution of LLM agents, streamlining the transition from research to production. This setup ensures that the environment is pre-configured and reproducible across different machines.
- Scalable Training Infrastructure: Integration with Ray and Joblib points to the need for robust distributed computing infrastructure. Deployers should ensure their platforms can support scalable agent training, allowing for the generation and processing of vast numbers of trajectories necessary for effective RL and SFT.
- Data Security and Isolation: The emphasis on securely stored data within the Docker image addresses critical concerns for healthcare deployments. Infra teams can be confident in the isolation and integrity of sensitive biomedical data during agent interactions.
Tradeoffs and Limitations:
- Complexity of Open-Ended Tasks: While structured queries are easier, open-ended bioinformatics tasks remain challenging. This indicates that while progress is being made, significant research is still needed for LLMs to reliably tackle highly ambiguous or less verifiable computational problems in medicine.
- Verifiability as a Bottleneck: The observation that less verifiable tasks are harder to learn highlights a fundamental limitation. Developing robust feedback mechanisms and reward functions for inherently ambiguous problems is a key challenge.
- "Stuck in Loop" Problem: The consistent failure mode where agents get "stuck in the expert loop" underscores that current agentic architectures still struggle with complex decision-making, exploration, and recovery from suboptimal states. This is a crucial area for future research in agent autonomy.
- Evolving Landscape: The speaker acknowledges that "a lot has changed" since the initial publication. This implies that while MedAgentGym provides a foundational benchmark, the field of LLMs and agentic AI is rapidly evolving, requiring continuous updates and re-evaluation of models and methodologies.
In summary, MedAgentGym marks a pivotal step towards building more capable and autonomous medical AI agents. It provides the tools and framework for practitioners to develop LLMs that can not only understand medical knowledge but also actively reason through and solve complex biomedical problems using the power of code.
Key Takeaways
- Code generation significantly enhances medical reasoning capabilities in LLMs, providing a considerable jump over purely language-based methods.
- Existing medical AI benchmarks are largely insufficient, lacking interactive, code-centric tasks and operating on smaller, static datasets.
- MedAgentGym introduces a scalable, interactive, and Dockerized training environment specifically designed for code-based biomedical reasoning, encompassing 72 tasks across 129 categories from real-world datasets like MIMIC-III and BioCoder.
- Joint training of coding and medical knowledge, combined with iterative interaction and debugging capabilities within the environment, is crucial for developing high-performing LLM agents.
- The framework supports advanced training techniques like Supervised Fine-Tuning (SFT), Offline Preference Optimization, and an outcome-supervised reward model for effective learning and performance improvement, including additional gains from rejection sampling.
- Models trained with MedAgentGym demonstrate strong generalization to out-of-distribution tasks, and the open-source nature facilitates broader adoption and acceleration of medical AI research.
About the Speaker(s)
This talk was presented by Ran Xu on behalf of a large collaborative team of co-authors from several prominent institutions. The contributing researchers are affiliated with Georgia Tech, Emory University, Yale, and UT Southwestern Medical Center. The speaker mentioned that the lead author could be contacted via email for additional questions, though the specific name of the lead author was not explicitly stated at that point in the transcript. The full list of speakers credited for this work includes Ran Xu, Yuchen Zhuang, Yishan Zhong, Yue Yu, Zifeng Wang, Xiangru Tang, Hang Wu, May Dongmei Wang, Peifeng Ruan, Donghan Yang, Tao Wang, Guanghua Xiao, Xin Liu, Carl Yang, Yang Xie, and Wenqi Shi.
Reviews
→ Top-rated talks at International Conference on Learning Representations 2026
All talks from International Conference on Learning Representations 2026