Skip to main content

trialdesignbench

PyPI version Python versions CI tests Mypy check Ruff check Documentation License

TrialDesignBench is a community-driven benchmark for evaluating AI agents in clinical trial design.

Scope

The benchmark currently focuses on two core tasks:

  • Task 1 (reproduction): Given a Statistical Analysis Plan (SAP) or study protocol, evaluate how accurately AI agents can reproduce the trial design using R.
  • Task 2 (design generation): Given high-level clinical requirements, evaluate the ability of AI agents to draft new clinical trial designs using R. Under development.

How it works

This Python package is a thin evaluation framework. It owns the task schema, task materialization, the grader, scoring rules, aggregation, and provenance. Harbor is the execution backend that runs first-party agent harnesses in Docker. The two meet only through files: Harbor task directories, a generated job.yaml, and the job directory Harbor writes.

Supported agents are claude-code (Claude Code), codex (Codex CLI), grok-build (Grok Build), and opencode (OpenCode). Other Harbor agents are refused because they cannot run closed book.

  • Hidden rubrics. Agents see the prompt template, the question skeleton, and the source document. Rubrics live only in each task's tests/ directory, which runs in a separate verifier container.
  • Decoupled grading. tdb grade is a pure function of the submission (output.json, output.R, trajectory), the rubrics, and the judge configuration. It runs the same inside Harbor, standalone, and in tests, so recorded runs can be regraded and external submissions compared.
  • Fail loudly. Every grading error is an explicit status and zeroes the reward; a missing R runtime or trajectory is never a pass.
  • Closed book, enforced. While the agent runs, egress is an allowlist of model API hosts; server-side web tools are disabled in the harness, the grader scans the trajectory for violations, and a network canary proves the policy holds.
  • One pinned image for agent and verifier: R with a dated CRAN snapshot, Python, Node, pinned agent CLIs and closed-book agent settings, and the pharma skills.

Installation

uv add trialdesignbench              # dataset, build, grade, report
uv add "trialdesignbench[judge]"     # + Anthropic SDK for the rubric judge
uv add "trialdesignbench[harbor]"    # + Harbor to run agents (Python 3.12+)

For development:

git clone https://github.com/BBSW-org/TrialDesignBench.git
cd TrialDesignBench
uv sync --dev

Quick start

# Canonical dataset from curated submissions and protocol/SAP Markdown
uv run tdb dataset import data/json/*.json --out tmp/dataset --documents docs/
uv run tdb dataset check tmp/dataset

# Shared environment image, then Harbor tasks
uv run tdb env build
uv run tdb build tmp/dataset --out tmp/tasks

# Run an agent with the network canary, then aggregate. The agent reads its
# provider's API key (here ANTHROPIC_API_KEY); the rubric judge always needs
# ANTHROPIC_API_KEY.
export ANTHROPIC_API_KEY=...
uv run tdb run --tasks tmp/tasks --agent claude-code \
  --model anthropic/claude-opus-5 --n-attempts 3 --canary
uv run tdb report jobs/<job-name> --format md

# Grade any directory with output.json and output.R, no Harbor needed
uv run tdb grade path/to/submission --rubrics tmp/dataset/<task_id>/rubrics.json \
  --out graded/<task_id> --trajectory path/to/trajectory.json

See the documentation for the dataset format, supported agents and their credentials, the judge, environment and network policy, grading rules, and reproducibility guarantees.

Release files for trialdesignbench 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trialdesignbench 1.1.0
File Size Uploaded
trialdesignbench-1.1.0.tar.gz 58.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trialdesignbench 1.1.0
File Interpreter ABI Platform
trialdesignbench-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 131.8 kB

Release files / trialdesignbench-1.1.0.tar.gz

Download URL trialdesignbench-1.1.0.tar.gz
Size 58.8 kB
Tags Source
SHA-256 checksum
How to use checksums
78cba9ff107ee4abcc1ae1e5a59064f795bbdc630323572d4bfdd2a1582c3ba0
BLAKE2b-256 checksum
How to use checksums
9a2cfaa633a7aca0445ae5c4e4552611175786ed2d000a5b7164ef4d1deb7367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / trialdesignbench-1.1.0-py3-none-any.whl

Download URL trialdesignbench-1.1.0-py3-none-any.whl
Size 73.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c42d7bacfb0aa226571c6a58db77b1d0be474ee569d36b7a5761a38dd4c8647
BLAKE2b-256 checksum
How to use checksums
8f6f14d9946830cadb1025d3ea305cea6e0b71e8b9f46ff3a837db54adc5e658
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page