Reconcile -> Compare -> Flag -> Shortlist -> Notify

Yield and Mass-Balance Explainer

After each batch the agent reconciles what was charged in against what came out and what was lost, then compares the loss to the normal band for that product. When a batch falls outside the band, it flags it and shortlists likely causes such as high wash loss or filtration carryover. A process engineer reads the shortlist and decides what to investigate.

The Problem

The batch closed at 91 percent yield. Normal is 96. Nobody knows why yet.

A batch finishes and the numbers get logged: charged in, produced, sampled, discarded. On paper the yield looks low, but the reconciliation lives in three places and no one runs it until month-end. By the time a trend shows up in the yield report, six more batches of the same product have run. The likely cause, a wash step carrying product to drain, is still guesswork.

What Changes

Every batch reconciled and explained while the run is still fresh.

The agent pulls charge and output quantities the moment a batch closes, computes the full mass balance against theoretical yield, and compares the loss to the product's normal band. If the batch is outside the band it flags it and ranks the likely causes from the pattern of where mass went missing. The engineer gets a one-page explanation the same day, not at month-end.

Humans stay in control: the agent computes the balance and ranks candidate causes, and the process engineer decides what to investigate and whether a deviation is warranted.

HOW THE AGENT WORKS

TRIGGERLLMAPIDECISIONACTIONWAIT
TRIGGERBatch close eventFires when a batch closes and its quantities are logged.
APIPull batch quantitiesReads charged-in, produced, sampled, and discarded amounts.
APILoad yield target and bandLoads theoretical yield and the product's normal loss band.
LLMCompute balance and check bandReconciles mass, computes loss and yield, and compares to the band.
DECISIONOutside normal band?
LLMShortlist likely causesRanks candidate causes from where mass went missing.
ACTIONSend mass balance reportDelivers the balance and cause shortlist to the process engineer.
The agent does not open a deviation or change the process. Your process engineer does. The agent removes the manual reconciliation and the month-end guesswork about where the mass went.

HOW TO BUILD IT

Three levels of depth. Pick the one that matches where you are.

For the ops person who needs to understand what's involved and brief their team.

Batch QuantitiesCharge, output, and loss from MES or the record
The AgentWorkflow engine + LLM
Process EngineerReads the balance and cause shortlist

WHAT YOUR TEAM PROVIDES ONCE

  • Mass balance - charged-in versus produced versus accounted loss per batch
  • Theoretical yield check - actual output against the recipe target
  • Loss band comparison - this batch against the product's historical range
  • Normal or abnormal flag - a clear call on whether the batch is in band
  • Likely-cause shortlist - ranked candidates like wash loss or filtration carryover
What happens day-to-day: a batch closes and its quantities land in the MES. The agent reconciles the balance and checks the loss against the normal band. If the batch is off, the engineer gets a short explanation with ranked causes the same day and decides whether to look deeper.

For the IT person or technical lead who needs to scope the integration.

INQUIRY SOURCES

Charge and output quantities from the batch record or MES
Recipe theoretical yields
Historical loss bands by product

WORKFLOW ENGINE (N8N)

Batch close event
Pull batch quantities
Load yield target and band
Compute mass balance
Outside normal band?
Shortlist likely causes
Send mass balance report

CONNECTS TO

MES (Werum PAS-X / Emerson Syncade / AVEVA MES)Read: charge and output quantities. Write: none
ERP (SAP / Oracle / Tally)Read: recipe theoretical yields. Write: none
Historian / data lake (OSIsoft PI / AVEVA / Aspen IP.21)Read: historical loss bands by product. Write: mass balance log
Notification (Email / Slack / Teams)Read: none. Write: mass balance report to engineer
WITHOUT PMS API

Without API access, someone exports the batch quantities and yield table to CSV after the run. The agent computes the same balance and emails the report. The trigger becomes a manual upload rather than an automatic batch-close event.

WITH PMS API

With API access to the MES and ERP, the agent reads batch quantities and yield targets on batch close and runs the reconciliation automatically. The engineer sees the explanation within minutes of the run ending. Best experience.

For the person who wants to build this agent step by step. Each node below maps to an n8n workflow node.

TRIGGERNode 1
Trigger - a batch closes
Listen for a batch-close event from the MES or watch a nightly quantities export.
Output: { batch_id, product_code, charged_in[], produced_kg, sampled_kg, discarded_kg }
APINode 2
API - load yield target and loss band
Call the recipe service and history store by product_code.
Output: { product_code, theoretical_yield_kg, loss_band: { low_pct, high_pct } }
LLMNode 3
LLM - compute mass balance and classify
Send quantities, theoretical yield, and the band. The model reconciles mass and flags in or out of band.
Output: { total_charged_kg, accounted_kg, loss_kg, loss_pct, yield_pct, in_band }
You are reconciling a chemical batch. Charged-in components: {charged_in}. Produced: {produced_kg} kg. Sampled: {sampled_kg} kg. Discarded: {discarded_kg} kg. Theoretical yield: {theoretical_yield_kg} kg. Normal loss band: {loss_band}. Compute total charged, accounted output, loss in kg and percent, yield percent, and whether loss is inside the band. Respond ONLY with valid JSON. No explanation.
INPUT
{"charged_in":[{"material":"API","kg":100},{"material":"solvent","kg":400}],"produced_kg":455,"sampled_kg":5,"discarded_kg":2,"theoretical_yield_kg":500,"loss_band":{"low_pct":2,"high_pct":6}}
OUTPUT
{"total_charged_kg":500,"accounted_kg":462,"loss_kg":38,"loss_pct":7.6,"yield_pct":91.0,"in_band":false}
DECISIONNode 4
Decision - inside normal band?
If in_band is true, send a short normal summary and stop. Otherwise route to the cause shortlist.
Output: { in_band: boolean, loss_pct }
LLMNode 5
LLM - shortlist likely causes
Send the balance and recent product history. The model ranks candidate causes with where to check each.
Output: { causes[]: { rank, cause, reason, check } }
You are a process engineer assistant. A batch of {product_code} lost {loss_pct} percent, above its normal band of {loss_band}. Where mass was accounted: {balance}. Recent history for this product: {history_notes}. List the most likely causes of the extra loss, ranked, each with a short reason and where to check. Respond ONLY with valid JSON. No explanation.
INPUT
{"product_code":"CMP-204","loss_pct":7.6,"loss_band":{"low_pct":2,"high_pct":6},"balance":{"loss_kg":38},"history_notes":"wash volume increased last month"}
OUTPUT
{"causes":[{"rank":1,"cause":"high wash loss","reason":"wash volume was increased recently and product is soluble in the wash","check":"mother liquor and wash filtrate assay"},{"rank":2,"cause":"filtration carryover","reason":"fines passing the filter cloth","check":"filtrate clarity and cloth condition"}]}
ACTIONNode 6
Action - send the mass balance report
Post the balance, in/out of band flag, and cause shortlist to the engineer's channel with the batch_id.
Output: One-page report with balance, flag, and ranked causes
MVP vs Advanced — Where To Start
MVP — START HERE
  • Read quantities from one nightly export
  • Reconcile balance for one product
  • Compare loss to a fixed band
  • Flag batches outside the band
  • Email a one-page mass balance
  • Engineer decides what to investigate
ADVANCED — ADD LATER
  • =+ Live batch-close trigger from MES
  • =+ Product-specific bands from rolling history
  • =+ Component-level balance, not just totals
  • =+ Cause shortlist tuned on past deviations
  • =+ Trend yield and loss by product and line
  • =+ Auto-draft deviation summary for engineer review

Full Video Walkthrough Coming Soon

Watch the agent reconcile a closed batch and return a mass balance with a ranked cause shortlist.

Register to be notified

Everything on this page is free to learn.

When you're ready to build — do it yourself or bring us in.

OTHER AGENTS IN LEASING & MARKETING

Matches recovered solvent to upcoming batches, recommends reuse, top up, or discard.
Drafts the end-of-shift handover with open batches, held items, and overnight alarms
Flags blanks, unsigned steps, and math errors before the record reaches QA
Recommends the minimum reactor clean between two products, with the residue check.

Frequently asked questions

Yield and Mass-Balance Explainer is an AI agent that reconciles charge versus output, flags abnormal loss, and shortlists likely causes.
The batch closed at 91 percent yield. Normal is 96. Nobody knows why yet. The Yield and Mass-Balance Explainer addresses this: reconciles charge versus output, flags abnormal loss, and shortlists likely causes.
No. Your team stays in control. The agent does not open a deviation or change the process. Your process engineer does. The agent removes the manual reconciliation and the month-end guesswork about where the mass went.