Aridhia DRE - Trusted Research Environment

Reflections from the TRE Communities Conference: Bringing AI to the data

This blog is the second part of two reflecting on our time at the TRE Communities Conference last month. You can read the first part, where we focus on how Federation was covered here.

Bringing AI to the data

The question of trust is equally important when we start introducing AI into TREs, and this was the focus of the session Scott and I presented.

Scott and Kim presenting at the TRE Communities Conference

Researchers increasingly want access to AI capabilities for writing and debugging code, extracting information from free text, generating reports and carrying out more complex, multi-step analyses. The challenge is making these capabilities available without introducing new risks to the data and the people whose information we're entrusted with. If researchers can't access the tools they need through approved routes, there's a risk they'll turn to alternatives outside the TRE.

With public AI services and coding agents, it can be surprisingly easy for sensitive information to end up somewhere it shouldn't.

We used Simon Willison's "lethal trifecta" to illustrate one of the more important risks with agentic AI. An agent that can access private data, read untrusted content and communicate externally can potentially be manipulated into sending that data somewhere it shouldn't go. Instructions hidden in a document or other material the agent is processing can be enough to trigger the problem.

Guardrails and instructions help, but they aren't sufficient on their own. The more robust approach is to remove or tightly control one of those capabilities. And that's where TREs have an enormous advantage. We already have controlled environments, restricted network access, governed software and processes for reviewing anything that leaves the workspace.

There are different ways to achieve this, from approved enterprise AI services through to models hosted within the TRE or fully isolated environments. Each comes with different trade-offs around capability, control, infrastructure and governance. Our AIRA framework is designed to support these different deployment approaches, allowing organisations to provide AI capabilities according to their own governance requirements, with controlled access and auditable interactions.

Showing what's already possible

Showing what's already possible We wanted to demonstrate what this can look like in practice, so we ran a live demo using tools we've been building within the Aridhia DRE. The demonstration brought together three applications, all running within a TRE workspace, with a locally hosted AI model:

AgentCoder, our AI coding agent, took two plain-English requests against the publicly available Breast Cancer Wisconsin dataset. One generated an exploratory analysis report, including tables, figures and summary statistics. The other built an interactive R Shiny application for exploring and comparing the data.

Airalock, our disclosure-checking tool, assessed the research outputs using 130 deterministic rules, supplemented by AI-assisted review. When we introduced names and locations into a modified version of the dataset, it identified the disclosure risks and flagged that the files shouldn't be released in that form.

Redact then identified and removed the personal information from the files, recording the decisions and producing de-identified copies without modifying the originals. We returned to Airalock to reassess the outputs and prepare an airlock submission, with the researcher's reasoning and assessment results available to the reviewer.

The coding agent used a locally hosted Qwen 3.6 model served through AIRA, with no external internet access. The model, data, scripts and outputs remained within the TRE.

An important part of the demonstration was that the AI wasn't simply producing answers that researchers had to take on trust. The analysis was performed through generated code, with the scripts and results saved so they could be reviewed and reproduced. The agent's actions were also logged.

It was great to demonstrate this end-to-end workflow live, from a researcher's initial question through to preparing their outputs for controlled release.

What we've learned getting AI tools into TREs

We also shared some of our lessons and experiences from getting these tools working inside TREs, including the things that haven't worked so well along the way.

One of the biggest lessons has been that running the model locally is actually the easy part. Most of the AI tools researchers want to use weren't originally designed for secure, network-isolated environments. Many assume they can access cloud APIs, download dependencies, authenticate with their own services or use very large models. We've found that simply pointing an application at a locally hosted model doesn't necessarily make it work offline.

Some tools still attempt to reach the internet at startup. Others assume access to external services, or don't consistently honour the local model endpoint they're configured to use. Even getting the software installed, with all its models, packages and dependencies, can require substantial work. And there's a surprising amount of information being sent to models before a researcher even asks a question.

For example, Qwen Code can send more than 50,000 tokens of instructions and tool definitions, while tools such as Stanford's Biomni agent can exceed 40,000 tokens. By comparison, our own TRE system prompt is around 1,200 tokens. Getting three of these tools working locally and offline involved more than 7,000 lines of code changes for Biomni, over 6,000 lines for AgentCoder and around 1,200 lines for VS Code integration. That's before considering the ongoing maintenance as upstream tools, models and dependencies continue to change.

These adaptations aren't just about getting the tools to run, either. They also give us the opportunity to integrate them properly with TRE governance, including researcher permissions, approved software and dependencies, controlled external access and audit trails.

Let the model work alongside the data

Another important lesson is that using AI effectively in a TRE is often as much a data engineering problem as an AI problem.

Rather than sending large datasets to a model and asking it to perform the analysis, we've generally found it works better to let the model understand the question, generate the appropriate code or queries, and then use conventional tools to process the data locally. This is particularly important when working with large datasets, limited memory and shared GPU resources.

The approach is faster, more efficient and easier to reproduce. It also means we can inspect the code and understand exactly how the results were generated. Managing the model's context is another challenge. Tool outputs, logs and intermediate results can consume far more tokens than the researcher's original question.

In one coding session we examined, the agent processed over a million input tokens to generate approximately 6,400 tokens of output.

Careful control of what the model sees, and when, makes an enormous difference.

Models need governance too

We also touched on something that is easy to overlook: bringing a model into a TRE should be treated much like bringing in any other software dependency. In 2024, JFrog reported finding around 100 models on Hugging Face exhibiting malicious behaviour, including models capable of executing code when loaded. One example established a reverse shell. It's a useful reminder that downloading a model from a public repository isn't automatically safe.

We suggested a practical model-ingress checklist:

  • Prefer safe weight formats such as safetensors, avoiding executable serialisation formats such as pickle.
  • Record the source, licence and exact model version, including file hashes.
  • Scan model files before allowing them into the TRE.
  • Perform the first load in an isolated environment without network access.
  • Review the model card, including training data, intended uses and known limitations.
  • Pin model versions for research projects so results can be reproduced.

None of these measures is particularly exotic. They're extensions of the same software supply-chain and reproducibility practices that TREs should already be applying.

What could we do together?

We finished our presentation with a few suggestions for things the TRE community could work on together. There is already a lot of excellent open-source work happening across the community, and we don't need every TRE provider or research organisation to solve the same problems independently.

Some practical opportunities we suggested were:

  • A shared synthetic dataset containing deliberately planted prompt-injection instructions, allowing different TREs and AI agents to be tested against common cases.
  • An AI annex to SATRE, covering areas such as model ingress, prompt logging, agent network access and model release.
  • Common wording for data access applications involving AI, including how proposed AI use is explained to patients and the public.
  • Practical disclosure tests for fine-tuned models, building on the work already underway with SACRO-ML.

Several of the open-source initiatives discussed at the conference, including K8TRE, FRIDGE and SACRO-ML, also have relevance to how we build and govern AI-enabled TREs. There's a real opportunity to share more of this engineering work, establish common ways of evaluating AI tools and models, and build on what different teams are already learning.

You can see the presentation slides here.