AI agent audit prototype · Built on Stockurai

Deviation triage for QA

Prepared for Jane Doe · Pharmaceutical manufacturing · December 3, 2026

Sample data for illustration.
DecisionHow to handle each new deviation: close, investigate or escalate
OptionsEscalate · Investigate · Close
Data sourcesQMS, Batch record system export, Equipment and EM data
PolicyCritical needs Head of QA; investigations per 21 CFR 211.192, 30-day SOP target
Deploying an AI agent for a decision like this? Request a formal proposal, or describe the agent’s decision to create a custom AI agent audit prototype.
STEP 01

Targets

Targets are what the system watches. Here, they are the deviations logged in the QMS, each with its area, batch and how many days it has been open.
TargetAreaBatchDays openStatus
DEV-2026-0412Fill-FinishB24-11871Active
DEV-2026-0415GranulationB24-11921Active
DEV-2026-0418PackagingB24-11752Active
DEV-2026-0409QC LabB24-11804Watching
STEP 02

Target detail

Where the feeds meet: the QMS (the deviation, prior investigations and CAPAs), batch records (what was made and where it is) and monitoring (equipment and environmental readings). Every signal is weighed against all three.

Room 214 Grade B counts (7 days)

DateLocationCFU/plateLimitResult
Nov 20Room 214 floor75Excursion
Nov 19Room 214 floor35Pass
Nov 18Room 214 floor25Pass
Nov 17Room 214 floor15Pass
Nov 16Room 214 floor05Pass
Nov 15Room 214 floor15Pass
Nov 14Room 214 floor05Pass

Deviation context

BatchB24-1187 · filled Nov 19, in quarantine
Prior history2 similar deviations in 12 months
Open CAPACAPA-2026-031 on filler RABS
Investigation dueDec 20, 2026 (day 30)
Feeds
QMSDeviations, CAPAs and prior investigation history · Every 15 minutes
BatchesBatch status, steps run and release holds · Daily
MonitoringEquipment alarms and environmental counts · Hourly
STEP 03

Alerts: what the system watches for

Alerts are code-free. Pick a field, an operator and a value. Each alert watches one thing, such as a count over its action limit or a repeat of an earlier deviation, and fires when it happens.

Edit alert

Grade B count above action limit
CFU per plate
Above
Action limit (5 CFU per plate)
1 Day
PreviewCFU per plate above action limit

Configured alerts

Count above action limitMonitoring
Equipment alarm during batchMonitoring
Batch filled or releasedBatches
Same issue in last 12 monthsQMS
Open CAPA on same equipmentQMS
Investigation past day 25 of 30QMS
STEP 04

Decision logic: alerts, conditions, plays and rules

Alerts evaluate data in real time. Conditions add triggered alerts up to a score, and plays organize the conditions. Rules turn a play’s score into a real-time recommendation on the live feed. The policy gate stops any recommendation the procedures don't allow: critical classifications wait for the head of QA, and every investigation carries its 30-day clock. Rules drive the recommendations, not AI.

Play: Classify each new deviation by risk

+15Product quality at risk
  • Count above action limit
  • Equipment alarm during batch
+10Batch already filled
  • Batch filled or released
+10Repeat issue
  • Same issue in last 12 months
  • Open CAPA on same equipment

Rules

Score ≥ 30ESCALATE
Score 15–29INVESTIGATE
Score < 15CLOSE

Policy gate

Critical classHead of QA approves
InvestigationPer 21 CFR 211.192
Close within30 days unless extended
ExtensionQA manager sign-off
STEP 05

Live feed

This is the screen the decision team watches. Each card is a proposed classification for one deviation, printed the moment its rule is met, with the score and time it fired.

Escalate (1)

DEV-2026-0412  Score 35 · Major + CAPA
Grade B count 7 CFU, batch filled, repeat issue; open CAPA
11/20 09:46 AM

Close (1)

DEV-2026-0418  Score 0 · Minor
Label roll change logged late; no batch impact, no repeat
11/20 11:02 AM

Investigate (2)

DEV-2026-0415  Score 15 · Full investigation
Granulator alarm mid-batch; no repeat; batch still in process
11/20 10:12 AM
DEV-2026-0409  Score 15 · Full investigation
HPLC alarm during assay run; no repeat; day 4 of 30
11/20 08:15 AM
STEP 06

Audit trail: one recommendation, start to finish

Every recommendation is logged and traceable. Anyone can see which records and readings arrived, which conditions were met, who approved the classification and how it compared with a manual classification.
DEV-2026-0412 — Audit trail

Data received

QMS feedDEV-2026-0412 logged 2026-11-20 08:30; 2 similar in 12 months
Monitoring feedRoom 214 floor plate 7 CFU, action limit 5
Batches feedB24-1187 filled Nov 19, in quarantine

Play evaluated → rule fired

✓ Product quality at risk (+15)
✓ Batch already filled (+10)
✓ Repeat issue (+10)
Score35 → ESCALATE
Policy gatePassed: major class, 30-day clock set

Decision

ActionEscalated as major, CAPA opened
Approved byHead of QA, 10:12

Outcome

Similar past case, manual classificationMinor, reopened as major on day 9
ResultRight tier on day 1, not day 9
STEP 07

Daily flags

A short daily list of things worth a look, separate from the live feed. Investigations nearing day 30, adverse trends in monitoring data, clusters of similar deviations and batches held up by open deviations.
QMS3 investigations past day 25 of 30
Extension or closure needed before day 30
MonitoringRoom 214 counts up 3 days running
Floor plates 2, 3, then 7 CFU; action limit is 5
QMS4 Fill-Finish deviations in 30 days
Usual rate is 1 a month; repeat condition armed
BatchesB24-1187 awaiting release review
Open deviation blocks batch disposition
STEP 08

ROI scoring and baseline

The optimization engine scores every decision. Every classification is measured against the specialist's manual classification, and against the tier confirmed after full review, closure and any repeat. The gap is the ROI you can measure.
TargetDecisionsRight tier first time (%)BaselineBest possibleCapturedResult vs baseline
Fill-Finish42918210050%+9 pts
Granulation36888110037%+7 pts
Packaging58949010040%+4 pts
QC Lab27857410042%+11 pts

Baseline: Specialist's manual classification. Best possible: Tier confirmed after full review. Sample figures; in a live installation, these come from the organization’s own decisions and data.

STEP 09

AI Agent Decision Data

The agent is one more feed. Stockurai doesn’t call or run the agent. It records every output and scores it against the rules, the decision makers and the outcome, in shadow: flags never block anything.
ClassifiesDeviation triage agent

Reads each new deviation in the QMS and proposes a tier, Minor, Major or Critical, before QA triage.

When it acts: When a deviation is logged; QA confirms or changes the tier.

Proposed tier:MinorMajorCritical
Matches final tier85%
Agrees with rules88%
Policy breaches flagged1
Tier changed after review10

Agent feed: sample records

TimeTargetProposed tierModelAgent’s reason
11/20 09:44 AMDEV-2026-0412Majorv3.1Grade B excursion with a repeat in the last 12 months
11/20 10:10 AMDEV-2026-0415Minorv3.1HPLC alarm during an assay run; no repeat
11/19 03:30 PMDEV-2026-0418Criticalv3.1Page missing from an executed batch record
11/18 08:20 AMDEV-2026-0409Majorv3.0Same label defect seen on the previous lot

Policy breaches flagged

DEV-2026-0418 · Critical
Critical tier proposed without routing to the Head of QA
11/19 03:30 PM · Flagged; Head of QA reviewed and classed it Major

Checked against the policy gate the moment each output arrives.

Agent's tier against the final tier after QA review, last 90 days

AgentMinorMajorCritical
Minor3840
Major3171
Critical023

Rows are the agent's tier, columns the final tier. The agent under-tiers more than it over-tiers: 4 deviations it called Minor were classed Major. Shaded cells are agreement.

Disagreements, graded on the outcome

TargetAgentRulesDecision makersWhat followedBetter call
DEV-2026-0409MajorMinorMinorDefect recurred on the next lot; reopened as MajorAgent
DEV-2026-0415MinorMajorMajorInvestigation found a failing detector; Major was rightRules
DEV-2026-0418CriticalMajorMajorNo product impact; Major confirmedDecision makers

Drift

PeriodModelAgreement
Augv3.086%
Sepv3.087%
Octv3.1new83%
Novv3.185%

Agreement dropped after the v3.1 update, mostly from packaging deviations tiered too low. That is the kind of shift the drift view is there to catch.

Where scoring is limited. Every deviation gets a final tier, so every proposed tier can be checked. The score is right tier first time. The audit produces scoring and evidence; it doesn’t certify the agent.
STEP 10

Fit and next steps

What we’d check first

Why
  • A daily, repeated classification with structured QMS, batch and monitoring data and clear tiers
To verify
  • Whether QMS data can be exported or read by API
  • How the SOP defines minor, major and critical
  • Validation and audit-trail needs for a regulated system
Extend with AI
  • Reading deviation narratives to suggest root causes and similar past cases

Next step: a formal proposal

ScopeThe decision, targets and data feeds
RulesRules and policy gate, written out
ROIHow ROI is measured against the current process
TermsSetup estimate, timeline and license terms
Where it runsThe organization’s own AWS account
Request a formal proposal Create a custom AI agent audit prototype

For IT and data teams: an AI data pipeline

Stockurai is licensed to researchers and institutions for real-time analysis of equity markets, with AI and machine learning built into the process. The same AI data pipeline can be built for this decision.

Design prototype prepared by Stockurai · Sample data for illustration only · stockurai.com