Ozgur Karahan AI Solution Engineer at Microsoft
03 · Context, what an agent can read before it answers

Dairy Digital Twin

Technical appendix.

This appendix gives the method behind the numbers of the article, the full results, the target architecture, and the limits. Every figure about the dairy is synthetic: the plant, its histories, the contamination and the laboratory results are produced by programs I wrote. None is a rate from a real plant.

A. The model dairy

One plant on the real map of Denmark, with a published history of 103 packing days.

Item Count
Farms66
Tanker rounds recorded2,336
Silo lots438
Make-lots (vats)3,480
Pack lots1,030
Packs made27,130,140
Pallets24,311
Truck trips1,113
Customers9: four retailer distribution centres, two wholesalers, two food manufacturers, one importer

The plant has four slicing lines and one grating line. The trimmings of two of the slicing lines feed the grater. Each machine has a daily clean and a weekly deep clean, with the machine taken apart.

The lot followed in section 1. 32,760 packs. Milk collected on one night from 12 farms by 7 tanker rounds (521.9 km in all), one silo lot, three make-lots the next day, sliced 43 days after the first pickup, 30 pallets, four trucks the next morning to a retailer's distribution centre (50 km), a wholesaler (206 km), a food manufacturer (95 km) and an importer (no distance recorded). Identifiers, times, litres, packs and pallets are records of the history. Every distance is the model's: a route on the public road map for each round's usual order of stops, not a measured trip.

B. The rule

The rule reads the records and gives every lot one of four states, with a reason: affected, uncertain, suspect, or outside the scope.

  • A product-contact swab is positive. The window opens at the end of the last verified deep clean of that machine and runs until the line is stopped; at the alarm, it ends at the alarm. Every lot whose run on the machine started in the window is affected.
  • A deep clean is verified when it is complete and signed, its pre-start checks passed, and the three swabs taken during the first run after it came back negative. A daily clean never counts. If any item is missing, the window runs back to the verified clean before it.
  • Offcuts carry the problem. A lot grated from the offcuts of an affected lot is affected. Where the offcut sheet is missing, the lots that could have received the offcuts are uncertain.
  • A finished pack is positive. The named lot is affected. The lots tied to it by machine, by make-lot or by an offcut sheet are suspect: held at once in the dairy's own stock, until a follow-up swab of the machine says more.
  • The scope never shrinks by itself. Where a later result would narrow it, the rule proposes the narrowing and a person decides.

The written procedure puts affected, uncertain and suspect lots under the quality manager's signature. In the measurements below, "the list" means the affected and uncertain lots; suspect lots are counted apart: they are held and under the signature, but the rule calls them affected only after a follow-up swab.

C. How a mock recall works

  1. The plant program builds a normal history of 103 days.
  2. A separate contamination program, which shares no code with the rule, hides a cause on one of the five machines. It decides which lots were truly contaminated and which of the routine samples already in the history would have come back positive. It writes this truth to a file the twin never opens.
  3. The twin receives only the laboratory's e-mails, each at its own time. The rule sets its list.
  4. The list is compared with the truth.

Nobody acts in a mock recall: no person stops the line or takes the follow-up swab the rule proposes.

Assumptions of the contamination program. All are mine; none is measured.

What Value
Where the cause sitsOn one product-contact machine, each equally likely. Causes in a drain, in one batch of milk or carried by a person are not modelled
A daily clean removes it10% of the time
A weekly deep clean removes it70% of the time
A lot run on the machine while the cause is thereContaminated with chance 0.6
Offcuts of a contaminated lotContaminate the lot grated in the same shift with chance 0.5
A contact swab of the machine while the cause is therePositive with chance 0.5
A finished-pack sample of a contaminated lotPositive with chance 0.2
The laboratoryReports about two to five days after the sample

Denominators. Fifty histories were built. In 29, routine sampling detected the first hidden cause. In the other 21 it never did; these are counted as recalls that never start, and a further cause was then drawn in the same history until one was detected. That gives 50 alarms: 37 began with a machine swab, 13 with a finished pack. The rule's results are therefore conditional on an alarm. The 50 histories were run three times and gave the same causes, truths and lists.

D. Results

The rule alone, 50 alarms

Question Result Limit
Is the first cause detected?29 of 50; 21 never. Those 21 contaminated 44 lots, and 1,268,560 packs of them left the dairyDetection follows the assumed chances above, on the plant's own sampling plan
Swab alarm (37): lots missed0 of 256 contaminated lotsZero in 37 says only "fewer than about one such recall in twelve". The contamination program spreads by machine contact, which is also the rule's idea
Swab alarm: width of the list12 to 46 lots, median 24. Median 69% of a list not contaminated (range 31% to 93%)One such lot in five ran on the machine while the cause was there; no test tells it from a contaminated one
Pack alarm (13): first list67 of 82 contaminated lots not on it: 55 held as suspect, 12 left outside the scopeNobody takes the follow-up swab in a mock recall
Pack alarm: laterA later routine result listed 61 of the 67, between 0.1 and 96 hours later (median 24). Six never
Time from the e-mail to the listMedian 0.6 seconds of calculation (0.24 to 1.99)One laptop. A person's reading time is not measured
Time before the alarmMedian 4.7 days from the start of the cause (2.4 to 7.7), about 70 hours of it in the laboratoryThe laboratory's days are an assumption

Two very wide lists. Two pack alarms gave lists of 171 and 275 lots. In both, the positive pack was grated cheese with no offcut sheet, and the plant's equipment data records no maximum keeping time for offcuts. The rule therefore listed as uncertain every lot ever sliced on the two feeding lines before that pack. In the wider case, 272 of the 275 lots were not contaminated, and four contaminated lots were missed: one was held as suspect, and three were left outside the scope because they were sliced after the pack's run on the slicer that fed the grater. This is a defect of my rule, found by the method.

The auditing agent and the cause agent, on the same 50 alarms. One model, one run per alarm, 100 runs, all completed.

Question Result Limit
Swab alarms: did the agent find a contaminated lot off the list?There was none to find. It named 41 lots off the list; none was contaminated
Pack alarms: did it find the lots the rule missed?It named 14 of the 67, all among the 55 already held. It named none of the 12 left outside the scope. It named 65 lots that were not contaminatedIn one alarm a single finding repeats the rule's own list of held lots
Did the cause agent name the right machine?First hypothesis: 22 of 37 swab alarms, 7 of 13 pack alarms. Where the cause sat on another machine than the alarm's: 0 of 3A swab alarm names the machine itself. A hidden cause leaves no record of its own
What did the code checks remove?17 of 238 findings and 2 of 64 hypotheses"Kept" means the cited records hold what the statement quotes. It does not mean the statement is true
Time and tokens per alarm, two agentsMedian about four and a half minutes and about 200,000 input tokensOne shared machine

The planted fault. Outside the 50 alarms, the demonstration history holds one fault no agent is told about: a daily clean cut short, with two steps not signed. The auditing agent found it in 7 of 7 runs on one model. On a second model it found it in 2 of 2 runs, and both times the code checks dropped the finding because it quoted a time from a reading it had not cited.

Model cost. Over 11 measured runs of the agent chain (six or seven agent runs each; ten of the eleven on the same alarm), the median cost was EUR 0.048 at the provider's list price, before tax. This excludes the platform and the machine that runs the twin.

E. The worked example of section 7

One alarm of the demonstration history: a positive swab on a slicer, with the rule's window running back five and a half days to the last verified deep clean.

Scope How it is drawn Lots Packs
By dateEvery lot started on any line of the plant during the rule's window601,462,660
By lineEvery lot started on that slicer since its last deep clean12342,960
By the ruleAffected and uncertain lots on joined records24 (20 affected, 4 uncertain)417,140

Packs are those of lots finished at the alarm. The scope by line leaves out 12 lots of the grating line (74,180 packs) that the rule cannot clear: four received the slicer's offcuts by record, four were grated afterwards before any verified clean of the grater, and four have no offcut sheet. This alarm has no hidden truth, so which of these lots would have been contaminated is not known. Of the rule's 417,140 packs, 379,280 had left the dairy for its nine customers and 37,860 were still in its cold store, where they were held at once.

The EUR 2 per pack of the article is an assumption for illustration. A real estimate needs the plant's own value per pack, its costs of return and disposal, and its own way of scoping today. It must not be multiplied by a number of incidents per year without evidence of that number.

F. The count of alert records

The European Commission publishes the notifications of its rapid alert system for food. I read the public records of the category "milk and milk products" for 2020 to 2025: 673 notifications, of which 666 had a readable detail record.

  • In 20 of the 666, a number of persons affected above zero is recorded.
  • In 230 of the 666, a follow-up added a country to the distribution list after the first notification. Among the 238 readable records for Listeria monocytogenes, it was 92; in 19 of them a follow-up added a lot.
  • These counts are a proxy. A country added to a record does not mean that more product was recalled, and a notification is not the same as a consumer recall.

G. The thirteen incidents of the map

The map of section 3 shows thirteen food incidents in ten European countries, from 2008 to 2025. Each figure on it was read in the document listed here, and is the count of that authority at the date of its report; later counts may differ. No company is named on the map, and none of this states who was at fault. An incident that touched several countries is drawn once, in the first country named below.

# Incident Sources read
12008, Ireland: pork, dioxinsReport on the Accounts of the Public Services 2010, Chapter 26: Pigmeat Recall Scheme, https://audit.gov.ie/media/fapf5rr5/2010-annual-report-chapter-26-pigmeat-recall-scheme.pdf
22008, Italy: buffalo mozzarella, dioxinsMozzarella di bufala, risultati finali dei controlli (joint Ministry of Health / MiPAAF communiqué, mirror), https://www.anmvioggi.it/altre-notizie/51241-mozzarella-di-bufala,-risultati-finali-dei-controlli.html
32009, Austria, Germany, Czechia: acid-curd cheese, ListeriaTwo clones of Listeria monocytogenes in Quargel cheese, Austria, Germany and Czech Republic (Eurosurveillance 15(16):19543), https://www.eurosurveillance.org/content/10.2807/ese.15.16.19543-en
42011, Germany: sprouted seeds, E. coliEHEC O104:H4 Outbreak Germany 2011: Final presentation and evaluation of epidemiological findings, https://edoc.rki.de/handle/176904/163
52014, Denmark: deli meat, ListeriaUdbrud af listeria i Danmark i 2013-14, https://www.ssi.dk/sygdomme-beredskab-og-forskning/sygdomsudbrud/arkiv/listeriaudbrud; Whole-genome Sequencing Used to Investigate a Nationwide Outbreak of Listeriosis Caused by Ready-to-eat Delicatessen Meat, Denmark, 2014 (Kvistholm Jensen et al., Clin Infect Dis 63(1):64-70), https://doi.org/10.1093/cid/ciw192 (abstract read at https://orbit.dtu.dk/en/publications/whole-genome-sequencing-used-to-investigate-a-nationwide-outbreak); TIDSLINJE Sådan har listeria-udbruddet udviklet sig, https://www.dr.dk/nyheder/indland/tidslinje-saadan-har-listeria-udbruddet-udviklet-sig
62017, France: infant formula, SalmonellaAssemblee nationale Rapport n. 1179 (Tome I): commission d'enquete chargee de tirer les enseignements de l'affaire Lactalis, https://www.assemblee-nationale.fr/dyn/opendata/RAPPANR5L15B1179-tI.html; ECDC-EFSA Joint Rapid Outbreak Assessment: Multi-country outbreak of Salmonella Agona infections linked to infant formula, https://www.ecdc.europa.eu/sites/default/files/documents/RRA-Salmonella%20Agona-France-Greece-Spain-01-2018.pdf
72017, Netherlands, Belgium: eggs, an insecticideIllegal use of Fipronil (FASFC/AFSCA incident archive), https://www.fasfc.be/foodfood-safety-incidentsarchive-food-safety-incidents/illegal-use-fipronil
82018, Hungary: frozen vegetables, ListeriaEFSA: Listeria - frozen vegetables likely source of outbreak (press release 180703), https://www.efsa.europa.eu/en/press/news/180703
92019, United Kingdom: hospital sandwiches, ListeriaListeria cases being investigated (sandwiches and salads in hospitals), https://www.gov.uk/government/news/listeria-cases-being-investigated
102022, Belgium: chocolate, SalmonellaUpdate: Multi-country Salmonella outbreak linked to chocolate products, https://www.efsa.europa.eu/en/news/update-multi-country-salmonella-outbreak-linked-chocolate-products; Disease Outbreak News: Multi-country outbreak of Salmonella Typhimurium linked to chocolate products - Europe and the United States of America (DON369), https://www.who.int/emergencies/disease-outbreak-news/item/2022-DON369
112022, France: frozen pizzas, E. coliInvestigation de cas groupés de syndrome hémolytique et urémique (SHU) et d'infections à STEC (point au 25 avril 2022), https://www.santepubliquefrance.fr/les-actualites/investigation-de-cas-groupes-de-syndrome-hemolytique-et-uremique-shu-et-1
122024, United Kingdom: sandwiches, E. coliUKHSA publishes report into UK's largest STEC outbreak, https://www.gov.uk/government/news/ukhsa-publishes-report-into-uks-largest-stec-outbreak
132025, France: soft cheese, ListeriaSanté publique France, 13 August 2025, and the joint press release of 12 August 2025 (references 2 and 3 of the article)

H. The target architecture

One row per part of the two drawings of section 6.

Part In the target The trap I noted
The way inMirroring for databases (SAP through SAP Datasphere); Data Factory copy jobs and pipelines; Azure Content Understanding for scanned sheets; Azure IoT Operations, IoT Hub or Event Hubs into EventstreamA mirror keeps only a short history: capture its changes yourself. Reading a handwritten sheet is not something I verified: a person confirms what the tool proposes
The traceability baseOneLake: a history keeper of rows that are only added; EPCIS 2.0 events; time-keyed tables for cleaning, monitoring, maintenance and laboratory results; a graph for the genealogy of lotsThe platform can read a table as it was earlier, but only as far back as old versions are kept. "As known at a time" must be your own filter on the rows
The trace engineThe rule as a service on Azure Container Apps, the only part that sets which lots are on the list, with a server of named reading tools (Model Context Protocol)The endpoint that reads the tables can lag behind them: refresh it before the rule runs
The startA Fabric Activator rule on each laboratory result, then Power AutomateThe rule does not wait for the action to finish: starting the same case twice must do no harm
The supervisorA Microsoft Agent Framework workflow on Azure Container Apps; its gates are codeThe state is saved only with a checkpoint store. After a restart a step may run again: every action must be safe to repeat
The agentsSix agents on Foundry Agent Service, each with its own identity and its own list of reading toolsAn empty list of allowed tools means every tool of the server. A laboratory mail is text from outside: treat what it says as data, never as an instruction
The personThe quality manager signs in with Microsoft Entra ID and signs each version of the scope in Microsoft Teams; the twin's page is the second doorIt is not certain that a card in a chat can ask for a fresh sign-in before a signature of this weight. If it cannot, the signature stays on the page
After a signatureDynamics 365 Customer Service: a recall case and a child case per customer. Azure API Management towards the partners' agents. Immutable Blob storage for each signed versionA child case cannot have child cases of its own. The gateway's agent interfaces are not in every pricing tier
Across all of itMicrosoft Entra ID and Entra Agent ID; Microsoft Purview; Azure Key Vault; prompt shields on the laboratory e-mail; Application Insights; Foundry tracing and evaluationsThe check of each statement against the readings it cites is not a product feature here: it is your own code

Where I read each capability, in Microsoft's documentation, on 30 November 2026:

  • Mirroring, and its change data feed: https://learn.microsoft.com/fabric/mirroring/overview and https://learn.microsoft.com/fabric/mirroring/extended-capabilities-delta-change-data-feed
  • Copy job, and the guide to choose a way in: https://learn.microsoft.com/fabric/data-factory/what-is-copy-job and https://learn.microsoft.com/fabric/data-factory/decision-guide-data-movement
  • Eventstream and Eventhouse: https://learn.microsoft.com/fabric/real-time-intelligence/event-streams/overview and https://learn.microsoft.com/fabric/real-time-intelligence/eventhouse
  • Fabric Activator: https://learn.microsoft.com/fabric/real-time-intelligence/data-activator/activator-introduction
  • Scanned sheets: https://learn.microsoft.com/azure/ai-services/content-understanding/overview
  • Reading a table as it was earlier: https://learn.microsoft.com/fabric/data-engineering/delta-lake-time-travel
  • The endpoint that reads the tables: https://learn.microsoft.com/fabric/data-engineering/sql-analytics-endpoint-metadata-sync
  • Microsoft Agent Framework, its checkpoints and its way to wait for a person: https://learn.microsoft.com/agent-framework/overview/ , https://learn.microsoft.com/agent-framework/workflows/checkpoints and https://learn.microsoft.com/agent-framework/workflows/human-in-the-loop
  • Foundry Agent Service, an agent's identity and its tools: https://learn.microsoft.com/azure/foundry/agents/overview , https://learn.microsoft.com/azure/foundry/agents/concepts/agent-identity and https://learn.microsoft.com/azure/foundry/agents/how-to/tools/model-context-protocol
  • Cards in Microsoft Teams: https://learn.microsoft.com/microsoftteams/platform/task-modules-and-cards/cards/universal-actions-for-adaptive-cards/overview
  • Parent and child cases: https://learn.microsoft.com/dynamics365/customer-service/use/customer-service-hub-user-guide-create-and-manage-parent-and-child-cases
  • The partner gateway: https://learn.microsoft.com/azure/api-management/agent-to-agent-api
  • Storage that cannot be changed: https://learn.microsoft.com/azure/storage/blobs/immutable-storage-overview
  • Traces and tests of agents: https://learn.microsoft.com/azure/foundry/concepts/observability

The two drawings mark what this documentation called a preview on that day. Check each capability at the time you build.

I. Two contracts an architect can reuse

Both are domain-neutral. The examples are invented for illustration.

A procedure step, written as data. Code reads the step; no model decides the order.

Field Example
Stepapprove-list
Comes afterdraft-ready, review-done
Who actsA named role: quality manager
What is approvedThe exact list, identified by a hash of its content
Stays valid whileThe list is unchanged; any change asks for a new signature
SourceThe controlled document and section the step comes from

The check on an agent's statement. Code keeps a statement only if all of these hold; otherwise it drops it, counts it, and shows the count to the person.

  1. The statement names the readings it rests on, and each is a reading the agent made in this run.
  2. Every identifier, time, date and number in the statement appears in a reading it cites.
  3. A record of one kind is cited from a reading of that kind, not from a text that only mentions it.

"Kept" then means that the quotes hold. It does not mean the statement is true: a person judges that.

J. Limits

  • One plant, synthetic data, and a contamination program built on the same idea as the rule.
  • No comparison with a working dairy: nothing here measures time or product saved against today's practice.
  • One agent run per alarm on one model; whether a second run says the same is not measured.
  • The drafts of notices were read by me, not by a food-safety professional or a lawyer.
  • No dairy professional has yet reviewed the model of the plant.

Follow the work, or invite me to speak about it.

New samples and notes go out on LinkedIn. To invite me to a talk or a panel on the five building blocks, message me there.