Zhen Wang

Internship · Jul – Sep 2026 · Shanghai

HGRAC Filing Assistant

AI Agent Development Intern · Data Science & Analysis (DSA), Pfizer R&D Center

A regulatory filing is one of the few places where a plausible answer is worth nothing. I spent three months building the system that produces one — and more of that time on proving it was right than on making it work.

This page is about structure and method, and shows no study data. The only figures come from the simulated study the work was developed against: one run classified 10,184 records into 3,792 pages of filings in about 20 minutes, with zero discrepancies against a colleague's independent engine.

The problem

Before a clinical study can be filed with Chinese regulators, the records belonging to Chinese participants have to be separated into the ones collected before that participant was randomised and the ones collected after — participant by participant, because each has their own randomisation date — and then rendered into submission-grade documents.

The two inputs disagree about everything. One is an application form written by a human in Excel, with no fixed layout: the same field may sit in a different row, carry a different label, or be spelled differently in the next study. The other is a folder of clinical datasets, each with its own column naming and its own idea of which column holds the date that matters. The work used to be done by hand, per study, by people whose time is worth considerably more than that.

How it works

The pipeline is deliberately boring in the middle: everything that decides anything is deterministic code, and the language model is kept to the edges, where being wrong is recoverable.

Architecture of the filing pipeline Two inputs — a human-written application form and a folder of clinical datasets — enter a four-stage deterministic pipeline: read the form into a machine-readable control file, resolve each participant's reference date, classify every record against it, then render the filing. A review layer of three language-model agents sits alongside the middle stages and can only comment, never decide. Every classified record carries a provenance note. Application form human-written Excel Clinical datasets one folder per study 1 · Read form → control file layout-tolerant parsing 2 · Resolve per-participant reference date 3 · Classify each record, before or after that date 4 · Render RTF first, then PDF if the box allows it Review agents — advisory only reconcile datasets · review classifications · triage open items swappable: hosted model or a local one Provenance every record carries why it was classified Deterministic core stages 1–3 never touch the network; all arithmetic lives here, not in a model
Click a stage to see what happens inside it — or send a record through the whole thing.
The model advises. Code decides. Every record can be traced back to the rule that classified it.

What I actually did

  • Made the form machine-readable. The parser locates fields by what they mean rather than where they sit, and writes a control file the rest of the pipeline reads. When it cannot find something, it says so and names the cell — it never guesses a default.
  • Rewrote the date logic as a per-participant cascade. The original approach picked one date column per dataset, which is wrong whenever a dataset mixes sources; the cascade resolves each participant's reference date from the best available evidence and records which rule fired. Doing this surfaced several systematic misclassifications the manual process had been quietly absorbing for years.
  • Added a provenance column to every classified record — which date it was judged on, and what it was compared against. A reviewer who does not read code can still check the result, and in practice that is the only kind of checking that actually happens.
  • Made the output survive its environment. Rendering originally required a headless browser the company's Linux server did not have, so nothing came out at all. The route is now RTF first — which is what gets submitted anyway — then a browser, then an office suite, with the chosen path printed at startup so a failure is legible instead of silent.
  • Built three review agents and kept them away from the decisions: one reconciles dataset inventories, one reviews classifications and flags disagreements, one triages the open items a human still has to answer. They can be pointed at a hosted model or a local one, because a regulated network cannot be assumed to reach the internet.

The agent that was confidently wrong

One review agent kept disagreeing with the deterministic classifier on records where the rule was not ambiguous at all. Rather than rewrite the prompt by feel, I ablated the input: hold the record constant and change one structural property at a time. The agent's answer flipped when I changed how often a date appeared in the row and where the field sat — without changing a single value. It had learned the shape of the data, not the rule it was given.

Two changes followed. The instruction became a hard constraint instead of a polite request, and every arithmetic comparison went back to deterministic code, leaving the model to explain rather than compute. I also compared several agent architectures — straight automation, a reasoning-plus-tool loop, plan-then-execute, and a multi-role council — against criteria I derived from the regulatory specification, which is how the final shape was chosen rather than assumed.

How correctness was established

A colleague had independently written a classification engine for the same regulation. Our outputs were reconciled line by line, and his implementation — not my reading of the specification — was treated as the definition of correct; his code was never edited, and every place where our interfaces disagreed is worked around on my side with the reason written at the point of the workaround. Re-running the whole pipeline on a later day reproduced identical output, which proves determinism rather than correctness, and the two tests answer different questions on purpose.

The data boundary

The agents only ever see file names, date field names and column names. Never participant identifiers — row numbers stand in for them — never measurements, never free text. The first three stages do not touch the network at all, and the API credential lives in a local environment file that is excluded from every package the project produces.

What this is not

  • It was handed over as documented code at the end of my internship, written for a department to adopt. Rolling it onto live studies is their next step, not something I can claim as done.
  • It was developed against a dummy study. It has never been run against a real study library.
  • The agent features cannot run on company machines, which have no external API access. Everything except the agents is usable inside the firewall.
  • A set of open items still needs the study team's confirmation, and part of the application form is still filled by hand.

R · Shiny · SAS dataset I/O · document rendering (RTF / PDF) · multi-agent orchestration · hosted and local model backends · regulated-environment constraints