MedData Escrow: Paying for Medical Data Only Once It Holds Up, With Claude on Amazon Bedrock
A hackathon build where an AI agent finds and checks medical research data, PayPal holds the money in escrow, and payment only goes through once the data passes. How Bedrock fits in, how we tested it, and what is still mocked.
The problem
Medical researchers buy datasets blind. They can't check the quality before paying, the vendor can't fully trust the buyer, and moving raw patient records around is a privacy risk. Take for example buying a used car with no test drive and no way to get your money back. Escrow already solves this for physical goods, where a third party holds the money until the item shows up as promised. MedData Escrow applies the same idea to data, with an AI agent doing the procurement work. We built it for the PayPal AI Hackathon in November 2026.
What it does
- A researcher describes their study in plain English.
- Claude on Amazon Bedrock ranks the datasets in the catalog for that study, and the researcher can compare up to three side by side.
- A sample quality and privacy check runs before any money moves.
- PayPal authorizes the listed price, so the money is held, not taken.
- The vendor delivers, the researcher confirms, and only then does PayPal capture the payment and pay the vendor (minus a 10% platform fee).
- After buying, the researcher asks questions in plain English and only gets back privacy safe aggregates. Raw records never leave the vendor.
There is also a procurement agent. You give it a study and a budget, and it searches, inspects, sample checks, and opens a PayPal escrow order, then stops, since only the human approves payment.
Where Amazon Bedrock fits
All model calls go through one client, built on the Anthropic Bedrock SDK, and Bedrock is opt-in with
LLM_PROVIDER=bedrock (region us-east-1 by default, credentials from the normal AWS chain). Claude does five jobs:- Ranking datasets for a study, using structured outputs.
- Turning a question into a typed query plan. The model never writes SQL. Our code compiles the plan into SQL, so a bad model reply can't run a query we didn't allow.
- A privacy second opinion that can only tighten. If the rule based screen allows a question, Claude can still refuse it, but it can never approve something the rules blocked.
- The sample check before money moves.
- The agent's tool loop.
Every one of these has a deterministic fallback, so the whole app runs with no AWS keys. This mattered more than I expected, as it meant the demo, the tests, and the evals never depended on a model being up.
Guardrails in code, not in the prompt
The agent's limits are enforced by code, where a prompt can only ask nicely. It can't go over the buyer's budget, it gets at most three sample checks per run, it never buys a dataset the buyer already owns, and it has no tool that releases money. Claude can also reword the one sentence summary under each answer, but any number it adds that isn't in the result rows gets dropped and replaced with the rule based sentence. This shows that the safest place for a guardrail is somewhere the model can't talk its way past.
How we checked it
Each AI piece has a number anyone can reproduce with
npm run eval , with no keys needed, and CI fails if a number changes without being committed. The repo has 1,066 tests.What | Result |
|---|---|
Retrieval on a held-out golden set | MRR 0.846, up from 0.664 for a word overlap baseline |
Hostile model red team | 26 of 26 attacks blocked, after fixing the 2 that first got through |
Money held on clean data with a truthful listing | 0 of 200 at each cohort size |
A planted leak on a flawed listing | Caught: it lifts a from-scratch model from AUC 0.69 to 0.81 |
The evals also found real bugs before any judge did: an imbalance check firing on 97% of small clean cohorts, the agent being willing to buy a COPD dataset for an Alzheimer's study, and one model reply running 300 tool calls.
What is real and what isn't
Important to also point out what is not done, since a write-up that hides this isn't worth much.
- Bedrock access was not enabled on my AWS account while we built this, so every number above comes from the deterministic fallbacks. Claude itself has not been evaluated yet.
- The app is hosted on Render with a Postgres database, not on AWS.
- S3, DynamoDB, and Lambda are planned, not used. The delivery link already expires after 900 seconds, but it is a mock link for now, where S3 presigned URLs are the planned version.
- All data is synthetic. No real patient data was used.
What I would do next on AWS
First, turn on Bedrock model access and rerun the same evals with Claude, so the fallback and the model can be compared on the same golden set. 2nd, swap the mock delivery link for S3 presigned URLs, which is a small change since the expiry logic is already there. 3rd, move the escrow sweep job, which releases or flags held payments, onto a scheduled Lambda.
So the core idea holds up: an AI agent can do the legwork of buying research data, as long as the money only moves once the data proves itself and the important limits live in code.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article