Most of the companies we speak to see the biggest opportunity for applying AI in their Good Laboratory Practice (GLP) studies. Since these are meant to go into the IND of a sponsor, they need extensive documentation. Regulators ask for this for everything from the study results themselves, to the validation done on the assays. They need this to build confidence that the study was done properly. As a consequence, many of these documents can be thousands of pages long.
Service providers have teams of people spending days at a time putting together and QC’ing reports for those studies. It is really important that these are done up to standard, as any mistakes can lead to delays in the sponsor’s program (and thus hurt the relationship with the sponsor). It seems like a perfect opportunity for AI automation: a lot of messy data across thousands of documents, a rigid set of rules that need to be followed exactly, and work that is not particularly exciting for humans. As we have written elsewhere, AI can also significantly help with avoiding delays by improving quality.
However, as with any new technology there are also new risks. GLP tries to deal with risks in the digital domain with Computer System Validation (CSV). But how exactly one should apply the principles of CSV to AI - and in particular LLM-based agents - is unclear. What does it mean for an AI agent to be “validated”? In this post, we make the case that current guidance and regulation fit naturally with AI agents. We suggest a framework for validating GenAI systems and give some practical tips on how to validate your AI workflows.
This post is a more accessible version of our white paper, which you can read here.
GLP and Computer System Validation
GLP arose as a regulatory requirement for pre-clinical safety studies to ensure quality and trust in the results. It came as a consequence of some studies having produced questionably accurate - and in some cases falsified - data. CSV is the logical extension of this to computer systems. It makes sure we can trust that the software programs we use to deliver GLP studies are fit for purpose.
A computerised system that has gone through CSV is said to be “validated”. Validation has to ensure that the system provides “consistent intended performance”, and that this has been tested to an extent commensurate with the risk of the system. GAMP 5 provides the step-by-step process for doing this validation:
- Intended Use and User Requirements: at this stage, a technical reviewer and QAU assess the intended use of the system and map out the requirements to deliver this consistently.
- Risk assessment: here, the team then needs to assess the risks of the system and its intended use. Each risk needs to be weighted by its severity (eg impact on a decision), probability of occurring, and likelihood of identification and remediation. The risk factors then determine the validation protocol and depth.
- Validation Protocol: In this stage, technical review and QAU work to define the set of tests and acceptance criteria that need to be run to confirm consistent intended use. The amount of testing and the stringency of the acceptance criteria need to be adjusted with respect to risk.
- Results and Review: once all the tests have completed, QAU will need to review the outcomes of the tests. Test failures need to be remediated and re-tests documented. Once all tests pass, QAU can sign-off for release.
- Release and Monitoring: after final sign-off from QAU, the computerised system is considered validated and can be used in GLP contexts. Upon release, it is on QAU to monitor continued intended performance and to ensure there is no drift.
Documentation of each step is critical for compliance - an inspector or auditor would expect to be able to access CSV records in the lab’s QMS.
For traditional software, the process here seems fairly clear. “Consistent intended performance” is easy to establish for traditional software as it is deterministic. Provided you give the same input, you get the same output. This is not the case with LLMs, however.
LLM-based agents and AI workflows
Large Language Models (LLMs) are very large AI models, made up of billions or even trillions of parameters. They are probabilistic systems, predicting the most likely next “token” (token = part of a word) in a piece of text. When they do this repeatedly, they can generate many paragraphs of human-readable (or not so readable) text. Code is also just text, so it turns out that LLMs are actually very good at generating that too.
When ChatGPT first came out in 2022, LLMs would respond to your query immediately. Question in, answer out. Over 2022-24 we found that these models would give better answers if they were allowed to “think” before they had to answer. This was called “Chain-of-thought”, where you would induce the model to break down a problem step-by-step and only answer after writing some paragraphs of reasoning first.
This reasoning was then combined with the models’ ability to write code to produce “tool calling”. I.e., the model could write some code to use tools it’s been given to take some action in the world (eg using a calculator). You then put the LLM with reasoning, coding ability and tools in a loop and voilà you have an LLM-based agent. The agent can now take actions autonomously and iterate until the task is complete. Each agent can do different tasks, depending on the model you use and the instructions and tooling you give it. To do this scalably, the industry has converged on the below system for designing and extending AI agents.
How an AI agent works
A model in a loop, with instructions and tools. It keeps going until the task is done.
- Think
- Act
- Check the result
An agent at work: drafting a validation report
- InstructionsReads the SOP and the report template
- ToolOpens the batch results export
- ToolCalculates accuracy and precision for each QC level
- ReasoningNotices one run failed acceptance, and checks the run log for why
- ToolFills in the tables and writes the summary
- ToolChecks its draft against the source data
- HandoverHands the draft to the analyst for review
It should quickly become clear how powerful such a system can be. In theory, any kind of knowledge work could be formalised and automated using AI agents. Common use-cases we see a lot of customer excitement for in GLP contexts are report drafting and report QC. We found that AI agents can cut these down from days to minutes, provided you give the agents the right context, SOPs, and tooling.
But to be able to use them in GLP studies, CSV is critical to get right first. And this can seem daunting due to the non-deterministic nature of LLMs - the same input will not necessarily give you the same output!
How you can validate AI workflows
The first thing to mention is that there is no regulation or guidance that requires software to be deterministic in GLP contexts. The only requirement is that it is validated to perform consistently for its intended use, in accordance with its level of risk. Processes that have variability are perfectly acceptable, provided the bounds on that variability are understood, documented, and commensurate with the level of risk the system poses. Examples of processes that produce variable output and are in use today include assays and analysts.
This means that the main questions around CSV of AI workflows are:
- How do we define the system?
- How do we assess (and minimise) risk?
- How do we test the system?
- How do we use the system?
We will take each in turn.
1. How do we define the system?
What you validate
Five parts, validated together and frozen at release. Each shows what a change to it means.
- ModelThe exact model version, with its reasoning effort and temperatureRevalidate
- Agent harnessThe loop that runs the model, at a pinned versionRevalidate
- InstructionsPrompts, skills and tool descriptionsRevalidate
- ToolingScripts, tools and MCPsRevalidate
- EnvironmentWhere it runs, eg a validated Windows VMAssess impact
For a particular AI workflow, the system is made up of:
- The model: the specific version of the AI being used to execute the workflow, as well as the parameters used to invoke the model (eg reasoning effort, temperature, etc)
- The agent harness: the system that orchestrates the LLM and harnesses it to act reliably in long sequences
- The instructions: the exact instructions given to the AI, such as prompts, skills, and tool descriptions
- The tooling: the scripts, tools and MCPs given to the agent to execute the task
- The environment: this is wherever the AI workflow is being executed. This could mean a Windows VM or your local desktop
All of the above will need to be validated as a single unit, as each can have an impact on the performance of the system. Consequently, if any of these change materially, the system will need to be revalidated. Therefore, we recommend doing thorough workflow development before validation. Validation should be the final step before release, at which point a workflow should be treated as “frozen”.
To manage environment updates (eg updates to the VM), we suggest making an impact assessment of the update and then revalidating for high impact changes. In our experience, any change to 1-4 above should be classed as high-impact and revalidated. If you use AI models from frontier model providers (Anthropic, OpenAI), you will need to keep tabs on when they plan to deprecate the model versions you use and plan for updates and revalidation accordingly.
2. How do we assess (and minimise) risk?
Risk assessment needs to be performed in broadly the same way as before: what is the risk, what is its impact, what is its probability, and how easily can a failure be spotted and remediated? Thus, risk assessment stays largely unchanged and can follow GAMP 5 guidelines. AI systems are unique only insofar as they aim to automate tasks that classically were only performed by humans. And as such the primary additional risk they pose is taking the human out of the loop and automating critical decision making.
Therefore, we strongly recommend that AI should primarily be assistive, and that all key decisions be approved by a human with appropriate authority. For example, AI should only ever be used to draft a report, never to write it without human review. A draft will need to be reviewed by a qualified human analyst and signed off for use. The analyst stays responsible for the deliverable. The level of human review needs to be adjusted for the level of risk. For example, drafting an internal project update email will require less review than the proposed processing of an LC/MS batch.
3. How do we test the system?
Testing is where the non-determinism becomes important. AIs can produce different outputs for the same input and they can fail in systematic ways. To remediate both, we suggest adopting the concept of “Evals” from the AI world. An eval is a set of test cases and acceptance criteria with which you score the AI. The test cases should be representative of real world usage, and as such include diverse samples to capture various edge cases (eg different matrices, numbers of samples, large vs small molecule, etc). We recommend including challenging cases, but not over-sampling outliers. The purpose is to measure performance of the system under conditions similar to what you expect to see in real studies. Your 10-15 most recent studies generally are good examples to do your validation on.
How an eval works
Build on one set of cases, validate on another, and run every validation case several times.
Each validation case, run 5 times
| Case | Run 1 | Run 2 | Run 3 | Run 4 | Run 5 | Average | Lowest | Result |
|---|---|---|---|---|---|---|---|---|
| Plasma, small molecule | 98% | 97% | 99% | 98% | 96% | 97.6% | 96% | Pass |
| Serum, large molecule | 96% | 95% | 97% | 94% | 96% | 95.6% | 94% | Pass |
| Urine, 400 samples | 99% | 99% | 78% | 100% | 100% | 95.2% | 78% | Fail |
| CSF, 12 samples | 95% | 97% | 96% | 98% | 96% | 96.4% | 95% | Pass |
Acceptance criteria: numerical accuracy above 95% on average, and no run below 80%. The urine case passes on average but fails on its worst run, which is why you need both. Illustrative numbers.
Each test case should be run with replicates: run the exact same test case and the exact same input parameters N times. This helps you capture the variability of the AI system on this workflow. Your acceptance criteria should also take this variability into account. We generally recommend defining acceptance criteria as a threshold on an average metric across replicates, plus a threshold on the metric for each replicate. For example, “numerical accuracy of the batch should be >95% on average, and no lower than 80% for any one run”. This way you ensure that expected performance is high, while not missing outlier failure cases.
Some important operational recommendations:
- Do not iterate on the workflow using the validation cases. In ML, we would call this “data leakage”; i.e. you are leaking your testing dataset into your training dataset. This is a problem because it will give you misleading metrics in the real world - the workflow will be overfit on your validation cases. Instead, we recommend you use a separate development set of cases that you can use to test the workflow on as you are building it. Regulators also recommend this approach, and further recommend you only let QAU see the detailed results of your validation cases.
- Your validation and development cases should be similar but not the same. The converse risk of the above is that your validation cases are completely different from your development cases. The end result of this is that you will be rejecting a workflow because you are testing it on something it was not built for. Generally, the validation cases should be like development cases, only with other data and metadata. None of the cases should require a change in workflow that has not been seen in the development cases. For example, if your validation case requires an additional set of tables in the document that none of your development cases had, you should expect the validation to fail. It’s an unfair test, because you’ve never demonstrated what needs to be done in this case. Here, you should either find a similar case from the past that you can put into your development set, or you should exclude the outlier from the validation.
- You need to adequately document your test runs and the system you used. For your QMS, you need to include proper documentation of the validation process. In the case of AI workflows, this includes the exact versions of each of the five components of the system we listed above, as well as the runs of the AI agent on the test cases (including the replicates). The runs need to consist of 1) the agent trace (the message history of the agent and the human), and 2) the workspace (the folder in which the agent’s input data, intermediate files, and final outputs are stored). Many commercially available agents (eg Claude Code, Codex, etc) store the agent trace on your computer, somewhere within their dedicated application folder, usually as
jsonl. We recommend storing the respective file together with the workspace in ZIP. The ZIP should be named in such a way so as to unambiguously identify the test case and replicate it belongs to.
4. How do we use the system?
Once the system has been validated and signed off by technical review and QAU, it is ready to be used in GLP studies by qualified personnel. At this stage, it is important for you to train the relevant personnel to use the system as intended. In particular, this means you have to make sure the users use:
- The correct version of the model, as well as the correct reasoning effort and temperature parameters.
- The correct version of the agent harness. Pinning the exact version of this is easier for some harnesses and harder for others. In general, it is easier to control the exact version in the command-line agent harness interfaces.
- The correct version of the workflow instructions and tooling. This includes things such as skills and prompts. We recommend using version control for these (eg Git) and asking users to pull these before running the workflow.
- The correct environment. Many CROs we talk to already use VMs to serve validated environments. We suggest using the agents there, provided you do not give them edit access to data more broadly.
These should also be recorded in your SOPs. Moreover, you should also record what the workflow cannot do. Since AI workflows are in theory infinitely flexible, the workflow can be used to do almost anything, even with scaffolding in place. As such, we recommend you set ranges on the allowed inputs for the workflow in your SOPs. For example, you may exclude the use of the workflow from studies that use correction factors, because you have not validated it for that use.
Finally, it is also important to monitor the performance of the system over time. Unfortunately, we are not aware of any other solutions that make this really straightforward. As a simple solution, we suggest reviewing the agent traces for each study you plan on submitting. Ask the user to send you their agent trace JSONL files and then render them with a script. Alternatively, ScienceMachine runs your acceptance criteria over the run automatically and lets you see your colleague’s agent traces by default.
Conclusion
AI agents are not deterministic, but GLP never asked for determinism. It asks for consistent intended performance, tested to a depth that matches the risk. We already hold assays and analysts to that standard, and AI workflows can meet it too.
In practice, it comes down to four things:
- Define the system as one unit. That means the model, harness, instructions, tooling and environment together. Freeze it before validation, and revalidate when any of the first four changes.
- Keep a human in the loop. The AI drafts and checks; a qualified person reviews, decides and signs off.
- Test with evals. Run representative cases with replicates, and set acceptance criteria on both the average and the worst run. Keep your development cases separate from your validation cases.
- Control how it is used. Pin the versions, record every run, and write down in your SOPs what the workflow is and isn’t validated for.
None of this is exotic. It is GAMP 5 applied to a new kind of system, plus a few habits borrowed from how AI teams test their models. The hard part is discipline. You need records of every version and every run, so an inspector can reconstruct exactly what happened in a study, even if rerunning it wouldn’t give the identical output.
If you’re thinking about bringing AI into your GLP studies, start where the risk is lowest and the benefit is easiest to see. QC is a good first candidate: the AI only flags issues, and a person decides what to do about them. Build your eval from your last 10–15 studies, and validate it before you rely on it.
We’re building ScienceMachine to make this easier, with pinned versions, a full record of every run, and evals on your own studies. If you’d like to talk through how this would work for your studies, get in touch.