arXiv:2610.18507cs.CLOct 2026

Manuscript Offprint

arXiv:2610.18507

The Last Mile of Coding Agents for Long-Document Tasks: An Empirical Study on Clinical Trial Protocol Digitization

Jiacheng Lin, Geoffrey Low, Nishit Agarwal, Rahul Jain, Afrah Shafquat, Mandis Beigi, Jimeng Sun

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

Abstract

Clinical trial protocols serve as the source of truth for study design, but are mostly written and used as unstructured PDF documents. Digitizing protocols turns static content into structured, machine-readable data that clinical software can analyze, validate, and execute. Coding agents, which select tools, execute code, and revise their approach as they work, are increasingly applied to such long-document tasks, yet it remains unclear how reliably they turn complete documents into accurate structured outputs. We study this question using protocol digitization as a testbed. We introduce TRIALPD-BENCH, an expert-annotated benchmark of 150 publicly available protocol PDFs spanning four task categories. Beyond final-answer performance, our evaluation measures evidence recall from agent traces, agent behavior, and cost. Across nine proprietary and open-weight models in five coding-agent harnesses, even the strongest agents do not fully solve protocol digitization. Our analysis further shows that agents usually locate the required evidence but fail in the last mile of transcribing and structuring it. We further develop TRIALSCRIBE, a domain-specific harness that equips coding agents with task skills and a verification loop. TRIALSCRIBE improves a locally served open-weight model by 6.2-59.4 points across eight metrics, enabling it to match or surpass proprietary models such as GPT-5.6-Sol.

1 Introduction

Recent advances in coding agents, exemplified by Claude Code (Anthropic) and Codex (OpenAI), have extended their use beyond software engineering to a broader range of complex tasks (Wang et al., 2026a; Lyttelton et al., 2026; Wang et al., 2026b; Lyu et al., 2026). These agents can select tools, generate and execute code, and revise their approach based on intermediate results, providing flexibility in how they organize and complete a task (Wang et al., 2024; Ning et al., 2026). Such capabilities make coding agents promising for long-document tasks, where relevant information may be distributed across many pages and different document structures may require different processing strategies. However, it remains unclear whether coding agents can reliably transform complex documents into accurate, complete, and structured outputs.

Clinical trial protocol digitization, which transforms protocol information into structured and machine-readable representations (Huser et al., 2015; Babaeipour et al., 2026), provides a high-stakes, real-world setting for investigating the capabilities and reliability of coding agents on long-document tasks. First, it is a representative long-document task. Clinical trial protocols specify the core design and operational requirements of a study, but are predominantly maintained as lengthy, unstructured PDF documents (Chan et al., 2025; Babaeipour et al., 2026). These documents contain heterogeneous layouts, complex tables, and information distributed across multiple sections, requiring systems to navigate long documents, integrate scattered evidence, and reconstruct structured relationships.

Second, it has direct practical value. When protocol requirements remain embedded in documents, they require repeated manual interpretation and translation into downstream systems, resulting in limited interoperability, reduced efficiency, and increased risk of inconsistencies and transcription errors (Babaeipour et al., 2026; Boland et al., 2012). Structured protocol representation is essential for making study requirements computable, interoperable, and reusable across the clinical trial life cycle (Huser et al., 2015; Richardson and Genyn, 2025; Babaeipour et al., 2026). Because these representations inform downstream trial operations, even small errors, such as altered eligibility thresholds or misplaced study activities, can change the intended

How reliably can coding agents handle long-document tasks? Clinical trial protocol digitization as a testbed

(a) Long, complex documents

Figure

(b) Tool-driven exploration

(c) Extraction quality varies across tasks

(d) Overall score vs. cost

Figure

(e) TrialScribe lifts an open-weight model to proprietary agents

Figure 1: Overview of this study. (a–c) Coding agents must localize evidence, interpret complex layouts, and link information across long protocols; output quality varies across tasks. (d) Overall score on TRIALPD-BENCH against average cost per run. (e) TRIALSCRIBE with Qwen3.8-27B versus the base model, Opus 5, and GPT-5.6-Sol.

study requirements.

In this paper, we study how reliably coding agents handle long-document tasks, using clinical trial protocol digitization as a testbed (Figure 1). Beyond final-answer performance, our evaluation protocol measures evidence recall from agent traces, agent behavior including vision use, tool errors, and interaction turns, and cost. Our contributions are as follows:

• We construct TRIALPD-BENCH, an expert-annotated benchmark of 150 complete protocol PDFs (median 122 pages) spanning four task categories: disease indication, eligibility criteria, objectives and endpoints, and schedule of activities. Each task requires locating evidence scattered across the full document and producing structured output that follows a USDM-derived schema.

• We evaluate nine proprietary and open-weight models in five coding-agent harnesses. Even the strongest agents leave substantial errors, reaching at most 67.4% endpoint F1 and 23.2% encounter recall. Agents usually reach the required evidence pages but fail in the last mile of reading and structuring it. Agents with similar accuracy can also differ several-fold in cost.

• We develop TRIALSCRIBE, a domain-specific harness that equips a locally served model with task skills and a verification loop. TRIALSCRIBE improves Qwen3.8-27B by 6.2-59.4 points across eight metrics, enabling it to match or surpass proprietary models such as GPT-5.6-Sol.

References (20)