CodeClinic: Evaluating Automation of Coding Skills for Clinical Reasoning Agents

Timothy Ossowski, Xinchi Liu, Danyal Maqbool, Vaibhav Dhanuka, Sheng Zhang, Hoifung Poon, Majid Afshar, Tyler Bradshaw, Junjie HuarXiv 2026

TL;DR

CodeClinic is a new benchmark designed to evaluate whether LLM agents can autonomously synthesize and compose reusable clinical coding skills rather than relying on static, pre-engineered toolboxes. To establish a strong baseline, the authors also introduce an offline autoformalization pipeline that converts natural-language medical guidelines into verified Python code libraries, improving agent consistency while slashing token costs by up to 40%.

What Problem Does This Paper Address?

Deploying LLM agents in healthcare—such as for intensive care unit (ICU) monitoring or patient state tracking—typically requires equipping them with a toolbox of domain-specific functions (e.g., a custom function to calculate a sepsis score). However, manually building and maintaining these toolboxes requires immense expert effort and fails to scale. Furthermore, clinical definitions and thresholds are rarely universal; they vary by hospital and evolve over time.

If an agent relies purely on zero-shot code generation to query electronic health records (EHRs), it often produces highly inefficient, unreliable reasoning chains. The core challenge is enabling LLM agents to dynamically generate their own modular, composable libraries of clinical skills that adapt to local institutional policies, using only a minimal set of verification data.

Methods

The authors tackle this problem from two angles: a evaluation benchmark and a synthesis pipeline.

  1. The CodeClinic Benchmark: It splits clinical reasoning into two distinct challenges:
  2. Longitudinal ICU Surveillance: Simulates a clinician monitoring patient trajectories. The agent is prompted every 4 hours over a 48-hour ICU stay to track 25 distinct clinical findings across 8 organ-system families, requiring it to maintain state and handle time-decaying variables.
  3. Compositional Information Seeking: Evaluates multi-step reasoning by stratifying 63 clinical concepts across 9 domains based on their dependency depth (e.g., computing a Sepsis-3 score requires first computing SOFA sub-scores, infection criteria, and antibiotic timing).
  4. Clinical Autoformalization Pipeline: Instead of generating code on the fly during a user query, this offline pipeline uses an iterative ReACT loop where an LLM agent explores the EHR schema, consults natural-language clinical guidelines, and writes Python functions. A separate verification agent tests these functions against a small training set. If the code fails, error traces are fed back into the loop for refinement. Once verified (accuracy $\ge$ 90%), the functions are saved to a static library for the inference agent to reuse.
Figure 4: Overview of the autoformalization pipeline. During the offline training phase, an LLM agent uses medical guidelines, verification examples, and EHR data to construct a library of executable tools. A separate verification agent evaluates this library on the remaining training data, with errors fed back in an iterative refinement loop. During the online testing phase, the learned tool library is provided to the inference agent, enabling more efficient computation and reduced token usage.

Datasets

The benchmark is entirely built on top of MIMIC-IV, a widely used, de-identified EHR dataset from a US academic medical center.

  • The Compositional Information Seeking task contains 63,000 queries across 42,311 unique ICU stays, split into a 10% training set (used for the autoformalization pipeline) and a 90% held-out test set.
  • The Longitudinal ICU Surveillance task consists of a stratified 2,000-stay benchmark providing 26,000 total evaluation checkpoints.

Key Insights and Ideas

  • The "Trajectory Illusion": Current frontier LLMs are reasonably good at making isolated, point-in-time decisions, but they struggle severely with temporal state tracking. A model might achieve high accuracy at individual checkpoints but fail completely when evaluated on whether it got an entire multi-day patient trajectory right.
  • Tracking State vs. Predicting Action: It is significantly harder for an LLM to maintain an accurate, multi-organ clinical picture of a patient than it is to simply guess the next high-level clinical action (e.g., "escalate care").
  • Autoformalization Beats Direct Finetuning for Complex Tasks: Traditional reinforcement learning finetuning (like GRPO) helps models learn shallow database search patterns (Level 1 difficulty). However, as tasks become more compositionally complex (Level 2 and 3+), direct finetuning performance plummets. In contrast, the autoformalization pipeline maintains robust performance by creating clean, modular code abstractions.
Figure 3: Left: Example sepsis-related question with its corresponding dependency graph. An- swering the query requires composing intermediate clinical concepts (e.g., Sequential Organ Failure Assessment (SOFA) score used in organ dysfunction definitions for sepsis, suspected infection) that must be recomputed over time. Right: Hierarchical taxonomy of MIMIC clinical concepts, organized by supercategory and associated sub-concepts.

Key Results

  • Longitudinal Tracking Failures: Even the strongest frontier model evaluated (Claude-Sonnet-4.6) achieved a decent 76.2% checkpoint accuracy but dropped to just 34.0% trajectory accuracy, highlighting the difficulty of long-horizon tracking.
  • Compositional Headroom: On zero-shot information seeking, Claude-Sonnet-4.6 led with 53.1% overall accuracy, leaving substantial headroom for future engineering. Performance steadily degraded as dependency depth increased, dropping from 58.4% on Level 1 tasks to 41.1% on Level 3+ tasks.
  • Efficiency Gains: Deploying the autoformalized Python libraries allowed inference agents to bypass raw database schema exploration. This reduced per-query token usage by up to 40% in longitudinal tracking and roughly 23% in information seeking, while universally improving or maintaining accuracy across almost all open-source and frontier models.

Limitations and Future Work

The authors note several key limitations:

  • Single-Center Bias: Because CodeClinic is grounded entirely in MIMIC-IV, the synthesized functions inherit the specific schema designs and clinical conventions of a single US hospital.
  • Small Verification Sets: The use of a small training split (100 examples per concept) means rare clinical edge cases might escape the autoformalization verification loop.
  • Guideline Quality: The natural-language guidelines used to seed the pipeline were synthesized by an LLM from PubMed abstracts, introducing a potential layer of drift from actual hospital policy documents.

Future directions include extending CodeClinic to handle multimodal data sources (like clinical notes and waveforms) and exploring how these verified libraries can be used to deploy smaller, highly efficient clinical agents for real-time bedside ICU monitoring.

Summary updated

BibTeX
@misc{ossowski2026codeclinic,
  author = {Timothy Ossowski and Xinchi Liu and Danyal Maqbool and Vaibhav Dhanuka and Sheng Zhang and Hoifung Poon and Majid Afshar and Tyler Bradshaw and Junjie Hu},
  title = {{CodeClinic: Evaluating Automation of Coding Skills for Clinical Reasoning Agents}},
  year = {2026},
  eprint = {2605.09675},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.09675},
}

Loading related content...

Figure