Back to Home

Bayer's PRINCE: What an 18,000-Study Pharma Agent Actually Looks Like in Production

14 min read
Sumeet Zankar

Sumeet Zankar

AI Solutions Specialist & Full-Stack Developer

One of the few public, end-to-end teardowns of a regulated-industry agentic RAG system that survived contact with real users and reached its second year. If you're building the next one — legal, finance, healthcare, internal compliance — there's a lot to steal here.

Most "enterprise agentic AI" case studies you'll read this year are pilots dressed up as production. A six-week sprint, a Streamlit demo, a press release, and a quiet retreat. So when Thoughtworks and Bayer published a 10,000-word architecture write-up on PRINCE on martinfowler.com and a peer-reviewed companion paper in Frontiers in Artificial Intelligence — covering a system that's been in users' hands since early 2024, with agentic orchestration added in November of that year — it's worth slowing down.

PRINCE (Preclinical Information Center) is not interesting because it's pharma. It's interesting because it's one of the few public, end-to-end teardowns of a regulated-industry agentic RAG system that survived contact with real users and reached its second year. If you're an architect designing something similar — legal, finance, healthcare, internal compliance — there's a lot to steal here. And a few things worth pushing back on.

This is for the engineers building the next one.

The problem Bayer was actually solving

Forget "drug discovery." The problem is much more mundane and much more common: 18,000+ preclinical study reports accumulated over decades, sitting as scanned PDFs across migrated systems, with structured metadata that's "incomplete, missing, or even contain[ing] incorrect annotations" (Martin Fowler).

The "gold standard" lives in the PDFs. The metadata lies. Boolean keyword search returns either nothing or everything. A toxicologist needs to answer questions like "Were piloerection, ataxia, eyes partially closed, and loose faeces observed in study T123456-2?" — a question that lives in a scanned 1990s report somewhere in S3.

This is not a pharma problem. This is the same problem every Fortune 500 enterprise has, dressed in a lab coat:

  • A graveyard of unstructured documents that nobody can search.
  • Structured metadata that the org no longer trusts.
  • Domain vocabulary that breaks every off-the-shelf retriever.
  • A regulator (or regulator-equivalent) who will ask: show me your sources.

If you've built RAG for legal contracts, regulatory filings, internal SOPs, support tickets, or audit trails — you've fought 80% of this same fight.

Architecture deep-dive

PRINCE evolved through three phases the team explicitly names: Search → Ask → Do. Search was metadata filters. Ask was vanilla RAG over the PDFs. Do is the multi-agent system that ships today. The interesting one is Do.

The high-level shape

                    ┌──────────────────────────┐
                    │   React Conversational UI │
                    └─────────────┬────────────┘
                                  │
                    ┌─────────────▼────────────┐
                    │  FastAPI + LangGraph      │
                    │  Orchestration Layer      │
                    └─────────────┬────────────┘
                                  │
        ┌─────────────────────────┼──────────────────────────┐
        │                         │                          │
        ▼                         ▼                          ▼
 ┌──────────────┐         ┌──────────────┐           ┌──────────────┐
 │ Clarify      │────────▶│ Think & Plan │──────────▶│ Researcher   │
 │ User Intent  │         │ (process     │           │ Agent        │
 └──────────────┘         │  reflection) │           │ RAG + SQL    │
                          └──────┬───────┘           └──────┬───────┘
                                 │                          │
                                 │     ┌────────────────────┘
                                 │     ▼
                          ┌──────┴─────────────┐
                          │ Reflection Agent   │
                          │ (data reflection)  │
                          └──────┬─────────────┘
                                 │ sufficient?
                                 ▼
                          ┌────────────────────┐
                          │ Writer Agent       │
                          │ (draft reflection) │
                          └────────┬───────────┘
                                   │
                                   ▼
                            Response + Citations

State persists in Postgres (via the LangGraph checkpointer), application state in DynamoDB, vectors in Amazon OpenSearch, structured data in Athena, observability in Langfuse, evaluation via RAGAS. Models are abstracted behind an internal unified OpenAI-compatible endpoint that fronts OpenAI, Anthropic, Google, and open-source providers — so a model failure triggers a fallback to a different provider, not a stack trace to the user.

That last bit is underrated. Most teams pick "their" LLM in the proof-of-concept and discover in production that uptime is bimodal. PRINCE treats model identity as a runtime decision.

The four agents (five if you count Document Planner)

1. Clarify User Intent. Not a retrieval step — a scope step. The first thing the system does when a user query lands is decide whether it can even be answered without disambiguation. As PRINCE expanded across toxicology, pharmacology, drug metabolism, and pharmacokinetics, a question like "what was the effect" became unanswerable without first asking "in which domain?". This is the system's "fail-fast" mechanism. If the model can't pin down a domain or data source, it asks the human before burning tool calls.

This is the cheap step everyone skips. It saves real money.

2. Think & Plan (Process Reflection). Inspired by Anthropic's "think tool" pattern. This step does not retrieve data. It reasons about whether the trajectory is correct. Am I picking the right tool? Is this the right next action? In a 50-step workflow, you cannot afford to discover at step 47 that you were on the wrong path at step 12.

The brilliant move: PRINCE separates process reflection (is the workflow on the right path?) from data reflection (is the evidence sufficient?) from draft reflection (is the output complete?). Three different concerns, three different agents. Most teams collapse all three into one "critic" and wonder why it gives generic feedback.

3. Researcher Agent. Coordinator over two retrieval modes:

  • RAG pipeline for unstructured PDFs. Hybrid retrieval with metadata pre-filtering, semantic kNN + keyword search weighted 0.7/0.3, query expansion (n=5 paraphrases), parallel hybrid search, then a bge-reranker-large cross-encoder rerank from ~20 chunks down to 7. Embedding via text-embedding-3-large. The 0.7/0.3 weighting wasn't theory — they tuned it on their corpus.
  • Text-to-SQL for structured Athena data. Dynamic schema injection (only the relevant schema components, not the whole catalog), few-shot examples retrieved from a separate vector "semantic layer," strict SELECT-only validation, 3-retry self-correction loop on SQL errors, hard cap at 50 rows.

Notice what's missing: there is no LLM-as-judge step on generated SQL. They tried it. They removed it. From the article: "the reviewing LLM sometimes incorrectly flagged valid queries as erroneous, hindering efficiency without a commensurate gain in accuracy." This is the kind of detail that only surfaces in real production. Add it to your mental list.

The team is also evolving the monolithic Researcher into a hierarchy of domain sub-agents (toxicology agent, pharmacology agent, etc.), each owning its own tools and prompt. This is the natural endpoint when "studies" mean three different things in three different schemas.

4. Reflection Agent (Data Reflection). Looks at the retrieved evidence and the original question and asks: is this enough? If not, it generates targeted follow-up questions and hands control back to Think & Plan, which kicks off another retrieval round. It receives the question + evidence, not the full workflow history — context discipline.

5. Writer Agent (Draft Reflection). Synthesizes the final answer with citations. Non-negotiable rules: every claim must be grounded in retrieved context, every citation must link back to chunk + study ID + page + exact quote. For longer outputs (regulatory drafts), a lightweight internal review loop checks for missing sections and inconsistent tables.

For document drafting (e.g. IND reports), the Frontiers paper describes a separate Document Planner Agent with a vector library of section-level prompt templates, plus a human-in-the-loop step where the user reviews and edits prompts before generation. That's a clever inversion: the human edits the plan, not the output.

The trust/governance design — this is the interesting part

If you only steal one thing from PRINCE, steal this layer.

Citations as a product surface, not a footnote

Every claim in the generated answer is hover-linkable to the underlying chunk, the source document, the page number, and the exact quote. This is not just provenance plumbing — it's the review interface. A toxicologist verifying a generated answer reads the claim, hovers, sees the supporting quote in context, and decides in seconds whether to trust it. The cost of verification collapses, and that's what unlocks adoption in a regulated environment.

Most enterprise RAG systems treat citations as a confidence-signaling decoration. PRINCE treats them as the human-in-the-loop interface itself.

Three reflection loops, not one

LoopQuestionAgentCatches
ProcessIs the workflow on the right path?Think & PlanBad trajectory, wrong tool, poor sequencing
DataIs the evidence sufficient?Reflection AgentThin coverage, missing context
DraftIs the output complete?Writer AgentMissing sections, inconsistent tables

Most "self-reflection" systems I've reviewed have one critic LLM that's asked to do all three jobs and is bad at all of them. Separating them is the cheap win.

Context discipline as a first-class design principle

Quoting the article directly: "PRINCE therefore avoids treating the prompt as one large container for all available information." Different stages receive different context. Text-to-SQL gets only the relevant schema slice. The Reflection Agent gets the question + evidence, not the full transcript. The Writer gets curated chunks + citation constraints, not raw retrieval output.

This is what the team calls "context engineering" and pairs with "harness engineering" (the LangGraph control layer: state, retries, pause points, fallbacks). The framing matters because it makes the design choices teachable — every step has a clear question to answer about what goes in and what's withheld.

Evaluation: RAGAS + Langfuse, two cadences

  • Dataset evals (faithfulness, answer relevancy, context relevancy, answer accuracy, semantic similarity) run on a curated SME-built dataset whenever workflow, prompts, or models change.
  • Live traffic evals run daily against production traffic — no ground truth, but you can still measure faithfulness and answer relevancy, and catch hallucinations escaping into prod.

The "evaluation pyramid" framing — eval at each agent stage, not just end-to-end — is the testing-pyramid analogy carried into LLM-ops. If you only eval end-to-end, every regression looks identical: "the answer is worse." With per-agent eval, you know which agent regressed.

Resilience as a system property

  • LangGraph checkpointer persists agent state in Postgres after every node.
  • User can manually retry a failed query and resume from the failed node — successful steps are skipped.
  • LLM fallback to a different provider on repeat failures.
  • Built-in retries at both the LLM call level and the node level.

This is mundane plumbing that determines whether your system has 99% or 99.95% effective availability. Most agentic demos do none of it.

What's reusable for non-pharma enterprise AI

Strip the toxicology vocabulary and PRINCE is a blueprint. Lift these directly:

  1. Search → Ask → Do as a roadmap. Don't build a multi-agent system on day one. Ship a metadata-filter UI, then a RAG-on-top, then agents. Users learn alongside the system.
  2. Clarify Intent as a fail-fast gate. Cheap LLM call, saves a fortune in downstream tool execution. Especially when your tool surface grows past ~5 tools.
  3. Three separate reflection loops. Process, data, draft. Don't merge them.
  4. Hybrid retrieval with metadata pre-filtering. The pre-filter is doing more work than the embeddings. Without it, you're doing kNN over millions of vectors when you could be searching tens.
  5. Text-to-SQL with dynamic schema injection + few-shot from a vector store. The "schema firehose" is a real anti-pattern. Inject only what's relevant.
  6. No LLM-as-judge on generated SQL. Counter-intuitive, but borne out in production.
  7. Citations as the HITL interface. Make verification cheap or you'll never get past pilot.
  8. Per-agent + end-to-end eval, dataset + live traffic, two cadences. The bare minimum for catching regressions in prod.
  9. Model abstraction behind a unified endpoint. Treat model identity as a runtime choice, not a build-time one.
  10. LangGraph checkpointer for resumability. Free win once you adopt LangGraph; criminal not to use it.

The single most transferable insight: separate context engineering (what the model sees) from harness engineering (what surrounds the model). These are different disciplines. Treat them as different.

Honest critique — what's missing or unproven

The case study is generous with architectural detail and stingy with hard numbers. A few things bother me:

No reported accuracy numbers in the technical write-up. The Frontiers paper mentions faithfulness, answer relevancy, context precision, factual correctness, and semantic similarity as evaluation metrics — but neither the Martin Fowler article nor the abstract I read commits to a specific score on a held-out set. We're told the system is "reliable" and that evals run daily; we're not told what reliable means in numbers. Trust me bro is not a benchmark.

Hallucination handling is the one area that feels hand-wavy. Citations make hallucinations detectable, not impossible. The system can still produce a citation that doesn't actually support the claim it's attached to (the chunk-claim alignment problem). The article doesn't describe an evaluator that checks citation-claim alignment specifically — though RAGAS faithfulness gets close. In a regulated environment, I'd want a dedicated grounded-citation evaluator gated on every response.

Cost and latency are unspecified. Multi-agent workflows with three reflection loops and parallel hybrid search across 5 expanded queries are not cheap. The article admits they prioritized accuracy over cost in early iterations. Where they landed — average tokens per query, p95 latency, $/query — would be the most useful number to publish, and it's absent.

Domain sub-agents are described as a future direction. The monolithic Researcher with a flat tool list is what's actually in production. The architectural cleanup is roadmap, not state. Worth noting because everyone's going to copy the diagrams that don't exist yet.

The "Do" phase claims (drafting regulatory documents in minutes vs weeks) lean on the Ciberspring summary rather than the primary sources I read. The Frontiers paper is clear that final regulatory submissions are still "authored and approved by qualified personnel" — which is the right answer. But the marketing-friendly numbers (90% reduction in review effort, etc.) are not where the engineering rigor lives. Discount them.

No discussion of adversarial robustness. What happens when a user tries to prompt-inject the Researcher through a query? What happens when one of the indexed PDFs (decades old, scanned, OCR'd) contains text that hijacks the Writer? In an enterprise context this is acceptable. The blast radius is internal and the user is trusted. But it's worth flagging if you're lifting this design into a customer-facing product.

Multi-agent doesn't mean autonomous. Worth saying out loud: every agent in PRINCE is on a rail. The "agency" is in tool selection and loop termination, not in open-ended action. This is the right call for production, but anyone selling you "autonomous agents" with this same diagram is overclaiming.

Takeaways

If you're an AI Solution Architect designing the next regulated-industry agentic RAG system, here's the short list:

  • Build the boring layer first. State persistence, retries, fallback models, observability, evals. The agent diagrams are the easy part. The harness is what survives.
  • Three reflection loops beat one critic. Process, data, draft. Different prompts, different inputs, different roles.
  • Context discipline beats context expansion. Bigger context windows don't fix the "stuff everything in" anti-pattern — they camouflage it.
  • Citations as the HITL interface. Make human verification cheap and you'll get adoption. Hide the sources and you won't.
  • Evaluate per-agent, not just end-to-end. Without it, every regression looks the same.
  • Treat model identity as a runtime decision. Build the unified-endpoint abstraction on day one. Cheaper than retrofitting.
  • Discount the marketing numbers, copy the architectural discipline. PRINCE is worth studying because of how the team thinks, not because of any single metric.

The honest summary: PRINCE is the most architecturally disciplined public agentic RAG case study I've read this year. It's not magic. Most of the moves are individually obvious. The lesson is in the combination — and in the fact that they shipped, kept it running, and wrote it down.

Steal liberally. Just don't pretend the regulated-industry trust layer comes for free.

Sources

Agentic AIRAGLangGraphEnterprise AICase StudyPharma

Enjoyed this article?

Connect with me on LinkedIn for more insights on AI, automation, and full-stack development.