Pull Variance -> Join Yield & BOM -> Explain -> Flag Repeats -> Analyst Reviews

Batch Cost Variance Explainer

This agent takes the price, usage, yield, and lot-size variance splits from your costing system and writes a plain-language story of why a batch cost more than standard. It ties the numbers to the batch event and the bill of materials so the reason is clear without hours of cross-referencing. It also tracks which products keep over-consuming so the pattern gets attention.

The Problem

The variance report said usage was up. It did not say why.

The costing system split the batch variance into price, usage, yield, and lot size, and left it there. The analyst spent the afternoon cross-referencing the batch yield, the bill of materials, and the purchase price history just to learn that the yield ran low and solvent had gone up. Multiply that by every off-standard batch in the month and the explanation never gets done. The recurring over-consumers hide in the noise.

What Changes

Say why the batch cost more, in one paragraph, per batch.

The agent reads the variance splits alongside the batch yield, the bill of materials, and the purchase price history, and writes a short narrative with the numbers, for example yield four points below standard and solvent price up nine percent. It ties each variance to the batch event so the analyst starts from an explanation, not a spreadsheet. It also surfaces products that over-consume month after month.

Humans stay in control: the agent writes the explanation and flags the repeat offenders, but your cost analyst confirms the story and decides whether a standard or a process needs to change.

HOW THE AGENT WORKS

TRIGGERLLMAPIDECISIONACTIONWAIT
TRIGGERCosting export readyFires when the period's costing variance export is available.
APIFetch variance splitsPulls the price, usage, yield, and lot-size splits per batch.
APIFetch yield, BOM, pricesPulls batch yield, the bill of materials, and purchase price history.
LLMWrite the variance narrativeWrites a plain paragraph per batch with the numbers and the primary driver.
DECISIONRecurring over-consumer?
LLMDraft repeat-offender summarySummarises products that over-consume across recent periods.
WAITHold for analyst reviewPauses so the cost analyst can read and confirm the story.
ACTIONSend report to analystPosts the narratives and the offender trend to the analyst's channel.
The agent does not post an adjustment or change a standard. Your cost analyst does. The agent removes the afternoon of cross-referencing behind each variance.

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.

Costing, MES & Purchase HistoryWhere variances and yields live
The AgentWorkflow engine + LLM
Cost AnalystReviews the story and decides

WHAT YOUR TEAM PROVIDES ONCE

  • Variance narrative - a plain paragraph per off-standard batch
  • The numbers - yield points and price moves, named
  • Batch tie-in - the variance linked to the batch event
  • Repeat offenders - products that over-consume month after month
  • Trend view - how a product's variance moves over time
What happens day-to-day: when the costing export lands, the agent joins each batch variance to its yield, bill of materials, and purchase prices, and writes the reason in plain words. It lists the products that keep over-consuming. The analyst reads the stories, confirms them, and decides what to change.

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

INQUIRY SOURCES

ERP costing variance export (SAP CO or material ledger)
Batch or MES yield data
Purchase price history

WORKFLOW ENGINE (N8N)

New costing export triggers the run
Pull variance splits, yield, BOM, and prices
Match batch ids across costing and MES
Quantify each variance bucket per batch
Write the narrative and rank offenders
Route batches that need an explanation
Send the report to the analyst channel

CONNECTS TO

ERP costing (SAP CO / Oracle / material ledger)Read: price, usage, yield, lot-size variances. Write: none
MES yield data (AVEVA / Rockwell / batch records)Read: batch yield, quantities. Write: none
Purchase price history (ERP purchasing / SAP MM / Coupa)Read: material prices over time. Write: none
Reporting channel (Email / Microsoft Teams / Power BI)Read: none. Write: variance narratives and trends
WITHOUT PMS API

Without API access, finance exports the variance, yield, and price files to CSV. The agent still writes the narratives and ranks offenders, but the join is only as fresh as the last export and some steps stay manual.

WITH PMS API

With API access to the costing, MES, and purchasing data, the agent explains every batch the day the export closes and keeps the offender trend current. 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
Schedule Trigger - runs when the export closes
Cron set to run after the monthly costing close, or on file arrival
Output: A run event with the period identifier
APINode 2
HTTP Request - pulls variance, yield, BOM, prices
GET the costing, MES, and purchasing endpoints or read the CSV export folder
Output: Raw variance splits with yield, bill of materials, and price history
APINode 3
Function - joins and quantifies each bucket
Match batch ids and compute the value of each variance bucket per batch
Output: A structured object of per-batch buckets, yield gap, and price moves
LLMNode 4
LLM - writes the narrative and flags offenders
Send the joined object to the model with the variance prompt
Output: { batch_id, narrative, primary_driver, numbers, recurring_offender, recurring_note }
You are a cost variance analyst assistant. Given the variance splits, batch yield, bill of materials, and purchase price history below, write a one-paragraph plain-language explanation of why the batch cost more than standard, naming the numbers, and state whether this product is a recurring over-consumer. Variance: {variance}. Yield: {batch_yield}. BOM: {bom}. Prices: {prices}. History: {history}. Respond ONLY with valid JSON. No explanation.
INPUT
{"variance": {"price": 900, "usage": 300, "yield": 1200, "lot_size": 100}, "batch_yield": {"actual": 88, "standard": 92}, "bom": [{"material": "solvent", "share": 0.6}], "prices": {"solvent_change_pct": 9}, "history": {"solvent_over_months": 4}}
OUTPUT
{"batch_id": "B-2207", "narrative": "This batch ran 2500 over standard, driven mostly by yield. Actual yield was 88 versus a standard of 92, four points low, which added 1200. Solvent price rose 9 percent, adding 900 on the price bucket. Usage and lot size were minor.", "primary_driver": "yield", "numbers": {"yield_gap_points": 4, "solvent_price_up_pct": 9}, "recurring_offender": true, "recurring_note": "solvent has over-consumed on this product for 4 straight months"}
DECISIONNode 5
IF - routes batches that need explaining
Pass when the batch is off standard beyond a set threshold
Output: A filtered set of narratives and offender flags
ACTIONNode 6
Send Message - posts the report to the analyst
Format the narratives and trend and post to the analyst email or Teams channel
Output: A message in the analyst channel
MVP vs Advanced — Where To Start
MVP — START HERE
  • Start with one product family and a single variance export
  • Join batch yield and the bill of materials by batch id
  • Write one narrative per off-standard batch with the numbers
  • Send the batch stories to the analyst in one report
  • Have the analyst confirm each story before anything is acted on
  • Track over-consuming products in a simple running list
ADVANCED — ADD LATER
  • =+ Connect costing, MES, and purchasing by API for close-day explanations
  • =+ Add purchase price trends to separate market moves from usage
  • =+ Rank recurring offenders by total cost impact across periods
  • =+ Tie each variance to the batch record event for a direct link
  • =+ Draft a standard-review note for the analyst when a product drifts
  • =+ Feed confirmed narratives into a Power BI trend for the costing team

Full Video Walkthrough Coming Soon

Watch the agent explain a batch overrun in one paragraph and flag a product that over-consumes every month.

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

Frequently asked questions

Batch Cost Variance Explainer is an AI agent that turns batch cost variance numbers into a plain story and flags repeat offenders.
The variance report said usage was up. It did not say why. The Batch Cost Variance Explainer addresses this: turns batch cost variance numbers into a plain story and flags repeat offenders.
No. Your team stays in control. The agent does not post an adjustment or change a standard. Your cost analyst does. The agent removes the afternoon of cross-referencing behind each variance.