arXiv:2610.37459cs.AIOct 2026

Manuscript Offprint

arXiv:2610.37459

M4Bench: Evaluating Procedural Specification for Clinical EHR Derivation Agents

Hannes Ill, Rafi Al Attrach, Rajna Fani, Ahram Han, Ryohei Yamamoto, Marlene Louisa Moerig, Dukyong Yoon, Leo Anthony Celi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Clinical research over electronic health records depends on derived variables whose definitions sit outside the schema, in item codes, time windows, missingness rules, and output-grain choices that change cohorts and downstream conclusions. We introduce M4Bench, 28 clinical derivation tasks across 15 task families on MIMIC-IV and eICU, to test whether AI coding agents can reproduce such derivations and how clinician-reviewed agent skills change their results. Its controls decompose the value of skills into specification completeness, delivery format, and schema familiarity. In a Docker-isolated Codex campaign (GPT 5.4 Mini and GPT 5.5), skills raise reward, the mean match rate over scored output columns, by 0.136 over the no-skill baseline, with 26 of 28 tasks improving. Specification completeness accounts for most of this gain: on an eight-task control subset, an operational spec alone raises reward by 0.162, and skills add only 0.024 on top, a difference indistinguishable from zero. On a ten-task subset, decoy skills score like no skill and raw reference SQL nearly matches targeted skills, arguing against generic context or the skill format as the explanation. Schema obfuscation and restructuring preserve 86% and 70% of the skill gain (GPT 5.4 Mini, 26 MIMIC-IV tasks), a descriptive robustness check rather than a bound on memorization. A descriptive Claude Code replication on all 28 tasks (Opus 4.7 and Sonnet 4.6, 560 runs) is directionally consistent (+0.120, 21 of 28 tasks improving). These gains are partial agreement with the reference, not completed tasks: only 25 of 280 with-skill and 13 of 280 no-skill Codex runs pass every strict check, and skills barely change which rows agents return (key F1 +0.003). Skills are released as a versioned, clinician-reviewable markdown delivery format, with a family-level reference-validity audit. M4Bench releases tasks, skills, evaluation code, and sanitized per-run evidence as an open-source benchmark.

1 Introduction

Observational clinical research using electronic health records (EHRs) commonly relies on derived variables: severity scores such as Sequential Organ Failure Assessment (SOFA) [Vincent et al., 1996] and Acute Physiology Score III (APS-III) [Knaus et al., 1991], organ-dysfunction measures such

40th Conference on Neural Information Processing Systems (NeurIPS 2026). Track on Evaluations and Datasets.

Figure

Figure 1: M4Bench evaluation pipeline. Each task pairs a task card with a DuckDB clone whose reference targets are removed. The primary NO-SKILL-WITH-SKILL comparison and matched controls test specification completeness, reference-code structure, and schema familiarity under sandboxed execution and contamination auditing.

as Kidney Disease: Improving Global Outcomes (KDIGO) acute kidney injury staging [KDIGO Acute Kidney Injury Work Group, 2012] and Model for End-Stage Liver Disease (MELD) [Kamath et al., 2001], and cohort-defining phenotypes such as suspected infection and Sepsis-3 [Singer et al., 2016]. These variables are rarely available as simple columns. They are reconstructed from raw tables whose clinical meaning is distributed across item identifiers, units, documentation practices, time windows, and dataset-specific conventions, and the implementation choices behind a single derivation change cohort membership, score distributions, and downstream conclusions in observational studies [Johnson et al., 2017, 2018, Ostropolets et al., 2023].

Modern agents can inspect schemas, execute SQL, debug code, and iterate on tests, and recent work measures their ability to translate clinical questions into SQL or to interact with EHR data [Lee et al., 2022, Shi et al., 2024, Jiang et al., 2025]. Yet clinical derivation tasks often require procedural knowledge that is invisible from schema structure alone. A SOFA implementation, for example, needs the score definition plus how vasopressors are encoded, how oxygenation variables are paired, how ventilation status changes respiratory scoring, and how missing components are handled in a specific database release. This procedural knowledge is held by clinicians and embedded in community concept code such as the MIT-LCP MIMIC-Code repository [Johnson et al., 2018], but no benchmark we are aware of represents it as an auditable agent artifact.

M4Bench studies this gap as an evaluation problem. Rather than asking whether an agent can answer clinical questions in free text, M4Bench asks whether a coding agent can reproduce declared EHR research derivations and whether explicit procedural specifications change that behavior. The benchmark is motivated by a broader goal: enabling clinicians and clinical researchers to convert tacit procedural knowledge about EHR derivations into versioned, auditable artifacts that agents can use during implementation. The central question is how human domain expertise should be represented and evaluated for supervised research workflows.

The primary specification format is an agent skill: a markdown procedural artifact, in the spirit of Agent Skills [Zhang et al., 2025a], that summarizes the clinical rules, item identifiers, time windows, and output grain for one task family. Skills are reusable procedural artifacts and contain no hidden reference outputs. Each task and associated artifact is reviewed by two clinicians. This review supports face validity, output-schema consistency, and clinical-definition provenance.

The benchmark is designed around a controlled ablation (Figure 1). In the NO-SKILL condition, an agent receives the task instruction and database access, but no curated derivation procedure. This condition represents schema-plus-task access, not a fully specified clinical protocol baseline. In the WITH-SKILL condition, the same agent also receives the task-specific procedural skill. The submitted CSV is evaluated column by column against hidden reference outputs. The estimand is the change in agreement with declared reference implementations when curated clinical implementation knowledge is supplied.

Claims and non-claims. M4Bench estimates the native-schema WITH-SKILL-NO-SKILL reward difference for the same task, database, model, and execution protocol, with tasks weighted equally after model-level averaging. The tested procedural context comes from public MIT-LCP concept code, eICU conventions, clinician review, and task adaptations. Scores measure agreement with declared public-code reference derivations, not clinical correctness: clinician review flagged, for example, that broad culture inclusion can overcall suspected infection, that SOFA defaults missing organ components to zero, and that the vasopressor mapping omits angiotensin II (Appendix Table 9). Clinician-adjudicated and multiple accepted targets are the priority for future versions. The evidence is MIMIC-IV-dominant: 26 of 28 tasks use MIMIC-IV, and the two eICU tasks are cross-database probes, not evidence of database or hospital generality. M4Bench does not identify a causal effect of clinician review, provider-general behavior, memorization-free reasoning, or a unique effect of the skill format.

This paper makes three contributions:

  1. A benchmark object: 28 clinical EHR derivation tasks across 15 task families over MIMIC-IV and eICU, with clinician-reviewed skills, OS-level isolation, contamination-lint, and sanitized per-run audit logs plus a family-level reference-validity audit so that benchmark targets and known caveats are inspectable.

  2. A decomposition apparatus: decoy-skill, raw-SQL, operational-spec, and schema-perturbation controls separating specification completeness from delivery format, reference-code structure, and schema familiarity.

  3. A Codex finding under that apparatus, with a directionally consistent but descriptive full-coverage Claude replication: on an eight-task control subset, specification completeness explains most of the gain. Targeted skills improve Codex reward by +0.136 [0.085, 0.191] on 28 tasks (26/28 improving), and the corresponding Claude difference is +0.120 [0.067, 0.177] (21/28), but only 25/280 with-skill Codex runs pass all strict diagnostics and key F1 moves only +0.003.

References (52)