4 ready-to-build workflows

AI agent workflows for Dairy, poultry & cold chain

Triage cold-chain excursions across a milk route, answer farmers about rates and payments in their own language by voice, and escalate flock and quality alerts — with every condemn, hold and payout human-approved.

Each recipe below is expressed only in VegaDūta's real workflow building blocks — Trigger, Agent, Knowledge, Condition, Approval, Output, Tool (MCP), Voice, Device, Loop, Code and Parallel — so it maps 1:1 to something you can assemble in the Workflow designer. Consequential actions always pass a human Approval step.

1. Cold-chain excursion triage across a milk route (device-triggered, 2 agents)

Today: the bulk milk cooler at each village chilling centre has a dial thermometer and a temperature register, and the operator writes a reading into it twice a shift — usually both readings at once, at the end. The insulated tanker has a data logger whose chart nobody looks at until there is an argument. When the plant's chilling supervisor suspects a load ran warm, he phones the centre secretary, who reads him the register over the phone, and the question 'can we tip this tanker into the silo?' gets answered at the dock, from memory, by whoever is senior and awake. The 3am excursion is the one nobody hears about until the platform test at 7am.

Trigger: Device (cold-chain telemetry — temperature excursion on a BMC or tanker)

How the workflow runs

  1. Device

    An excursion is reported. A Device Control node watches the cold-chain telemetry stream from the bulk milk coolers and route tankers. When a unit breaches its threshold — or stops reporting — it fires with the unit id, the reading series and the route. The telemetry gateway has no first-party connector; it reaches the workflow via the device/Webhook path and is read back with a Tool (MCP) node.

  2. Code

    Compute the exposure arithmetically. A Code node does the maths on the reading series — minutes above threshold, peak, reporting gaps — deterministically, before any model sees it. Numbers a decision rests on should be computed, not generated; the agent then reasons about figures it did not invent.

  3. Loop

    Map: one pass per affected unit. A route-wide event can implicate several coolers and tankers at once. A Loop node fans a cheap triage agent across each affected unit — isolated context per unit, so a six-unit incident is handled exactly like a one-unit one.

  4. Agent

    Triage agent links exposure to lots. Per unit, the agent takes the computed exposure plus the collection and dispatch timestamps and returns strict JSON: which collection lots sit inside the affected window, which centres and farmers they came from, and the severity band the SOP assigns. It assembles the evidence — it never declares the milk fit.

  5. Agent

    Reduce: incident summary for the route. A reducer agent rolls the per-unit findings into one route incident: the implicated lots, the worst exposure, the farmers and centres involved, and the SOP's prescribed options (re-test / divert to a lower-grade use / hold pending lab / condemn) as OPTIONS, ranked with reasons.

  6. Approval

    Quality manager decides disposition. An Approval node holds the disposition. Condemning, diverting or releasing a load is a food-safety decision with a person's name on it — the workflow presents the reconstructed evidence and the SOP options, and the quality manager chooses. Nothing is auto-cleared and nothing is auto-condemned.

  7. Output

    Notify the route + write the record. On the decision, an Output node pushes the instruction to the route supervisor and tanker driver on WhatsApp (and voice/SMS where data is patchy), and a Tool (MCP) node writes the disposition and its evidence trail back to the quality/MCU system, keyed to the incident id.

Channels & connectors

  • Device Control (cold-chain telemetry)
  • Webhook
  • WhatsApp
  • SMS/Twilio
  • Tool (MCP → quality / MCU system)
  • Approval / HITL

Outcome

Every temperature excursion becomes a reconstructed, lot-linked incident summary with SOP options on the quality manager's screen within minutes of the breach — instead of a chart nobody reads and a phone call to the centre secretary hours later.

Why it helps

The mechanism is reconstruction plus routing: the temperature series, the collection timestamps and the SOP all exist already, but at 3am nobody assembles them, and the register is written from memory anyway. Doing that assembly automatically turns a silent alarm into a decision-ready case, while the fit-or-not-fit call stays with the person accountable for it.

Build spec

2 agents1 triage agent (runs once per affected unit via the Loop node) + 1 reducer (runs once per incident). The Device trigger, the Code node's exposure maths, the Approval and the write-back are workflow nodes, not agents. · Pattern: Device-triggered map-reduce: Device → Code (deterministic maths) → Loop (map per unit) → reducer → quality-manager Approval

System prompt (paste-ready)

(Triage) Assess ONE cold-chain unit's excursion. Inputs: {unit_id, unit_type (BMC|TANKER), computed_exposure {minutes_above_threshold, peak_temp_c, gap_minutes}, threshold_c, collection_events[{lot_id, ts, centre, farmer_ids[]}]}. The exposure figures were computed upstream — use them as given and never recompute or 'correct' them. Return strict JSON {unit_id, affected_lots[], affected_centres[], severity (LOW|MED|HIGH|UNKNOWN), sop_clause_ref, evidence_note}. If the unit stopped reporting, severity=UNKNOWN and say so — a gap is missing evidence, never a favourable reading. You do NOT decide whether the milk is fit and you do NOT output a disposition.

Agent roles & model tiers

  • Excursion triage (per affected unit) Economy tier — runs once per affected unit on every alert including the noisy false positives, so this choice dominates total spend. Configure a fallback model on a second provider: a 3am provider outage must degrade the alert, not drop it.

    Link ONE unit's computed exposure to the collection lots inside the affected window and band it against the SOP. Strict schema-valid JSON. Missing telemetry is UNKNOWN, never 'fine'. No disposition, no fitness judgement.
  • Incident reducer (once per incident) Standard tier — cross-unit reasoning and SOP option framing; this is the one output a manager reads at 3am, with a fallback model configured for the same reason

    Aggregate the validated per-unit findings into one route incident: implicated lots and farmers, worst exposure, reporting gaps. Then list the SOP's disposition OPTIONS (re-test / divert / hold pending lab / condemn) with the reason each applies, ranked. Present options only — the quality manager decides. Cite lot ids and the computed readings; never estimate a temperature.

MCP connectors

  • Cold-chain telemetry gateway (BMC + tanker loggers) — via Device Control / inbound Webhook, then Tool (MCP): fetch the reading series for a unit between two timestamps and read its current state
  • MCU / milk-collection system — via Tool (MCP): list collection lots and dispatch times for the route and window, resolve each lot to its centre and farmer ids
  • Plant quality system — via Tool (MCP): write the approved disposition and its evidence trail against the incident id
  • WhatsApp / SMS — route supervisor and tanker driver instructions

Built-in tools

  • knowledge_search (scoped Knowledge collection: cold-chain SOP — thresholds, exposure bands, disposition options)
  • http_request (pull the reading series and collection lots; write the approved disposition)
  • user-defined tool `excursion_severity` (SpEL, sandboxed formula — no API calls, no code): input.minutesAbove > 120 ? 'HOLD_LOT' : (input.minutesAbove > 30 ? 'ESCALATE' : 'LOG_ONLY') — classifies for routing only, and 'LOG_ONLY' is a routing label, never a food-safety clearance
  • user-defined tool `excursion_sms_line` (SpEL): input.unitId + ' ' + input.minutesAbove + 'min above ' + input.thresholdC + 'C, peak ' + input.peakC + 'C — ' + (input.route ?: 'route unknown') — builds the one-line driver SMS in a fixed, scannable shape

Guardrails

  • FOOD SAFETY: neither agent may clear milk as fit. They assemble exposure evidence, cite the SOP clause and present options — the fit/divert/condemn decision is the quality manager's at the Approval node, recorded with the evidence that justified it
  • The `excursion_severity` tenant expression classifies for routing only. 'LOG_ONLY' means 'do not page the manager', it does NOT mean the milk is safe — no SpEL expression, and no agent, can release a lot
  • A telemetry gap is severity UNKNOWN, never an implicit pass — silence is missing evidence and is escalated, not treated as a normal reading
  • Exposure figures come from the Code node, not from a model: the agent reasons about minutes and peaks it did not generate, and is instructed never to recompute them
  • Severity bands and disposition options come only from the cold-chain SOP in the scoped Knowledge collection — no invented thresholds, no improvised 'it's probably fine'
  • Idempotent on the incident id — a re-fired alarm for the same excursion updates the existing case instead of opening a duplicate or re-paging the route

Cost strategy

Cost is N × (economy-tier, hard-capped triage) + ONE standard-tier reduce, where N is affected units — and cold-chain alarms are noisy by nature, so the per-unit pass MUST sit on the economy tier; that single routing choice is the dominant lever. The reducer's one call per incident is where the reasoning budget belongs. Both roles carry a fallback model on a second provider, because an incident at 3am is exactly when you cannot absorb a provider outage. Run the map in Parallel batches for wall-clock speed on a route-wide event without changing per-unit cost.

Output & delivery

The Device node fires on the excursion → a Code node computes minutes-above, peak and gaps deterministically → the Loop maps a cheap triage agent over every affected cooler and tanker → the reducer builds one route incident with SOP options → the quality manager picks the disposition at the Approval node → an Output node instructs the supervisor and driver on WhatsApp/SMS using the tenant's own `excursion_sms_line` format, and a Tool (MCP) node writes the decision and its evidence trail into the quality system. The plant encodes its OWN excursion thresholds in `excursion_severity` — a formula edit in the tool editor, no developer and no redeploy.

2. Farmer rate & payment queries, answered by voice in the local language

Today: the society secretary keeps the rate chart pinned above the collection window and answers the same three questions all morning from his personal phone — what rate did my milk fetch, why is it less than yesterday, when does the payment come. There is a WhatsApp group per village society where he forwards a photo of the rate board, and farmers who cannot read it call him instead. Most speak Kannada, Marathi or Telugu; the MCU screen is in English. When he is at the bank or on leave, nobody can answer at all, and the same query reaches the union office by phone a few hundred times a week.

Trigger: WhatsApp / Voice call / SMS (farmer asks about rate or payment)

How the workflow runs

  1. Trigger

    Farmer asks, in their language. A WhatsApp message or voice note, an inbound Voice call, or an SMS from the farmer's registered number starts the flow. The number identifies the farmer against the MCU register.

  2. Voice

    Understand speech in an Indian language. A Voice node uses Sarvam for Indian-language speech-to-text and ElevenLabs for natural spoken replies, so a farmer who sends a Kannada or Marathi voice note gets a spoken answer back in the same language rather than an English wall of text.

  3. Agent

    Resolve the question against the real record. An Agent node identifies the farmer from the calling number, then pulls their actual collection entries — quantity, fat, SNF, the applied rate slab — and the payment status from the MCU / procurement system via a Tool (MCP) node, and explains the rate in plain language.

  4. Knowledge

    Ground the 'why' in the published rate chart. A scoped Knowledge collection holds the union's published fat/SNF rate chart and payment-cycle policy, so the explanation of why today's rate differs from yesterday's is quoted from the actual chart — the same chart pinned above the collection window — never reasoned into existence.

  5. Condition

    Dispute or plain query?. A Condition node splits the traffic: a straightforward 'what was my rate / when is payment' is answered directly; anything that disputes the recorded quantity or test result, or asks for an advance or an off-cycle payment, is routed to a human.

  6. Approval

    Any money movement is approved. An Approval node holds every payment action — releasing a held payment, an advance, a correction after a disputed test. The agent can explain a payment; it can never trigger one on its own.

  7. Output

    Answer on their channel. An Output node replies on the channel the farmer used — spoken reply for a call or voice note, text on WhatsApp/SMS — and, where a payout has been approved and released by a human, the Razorpay UPI confirmation reference is included.

Channels & connectors

  • WhatsApp
  • Voice/Call
  • SMS/Twilio
  • Sarvam (Indian languages)
  • ElevenLabs (voice)
  • Razorpay (UPI)
  • Tool (MCP → MCU / procurement system)
  • Knowledge base
  • Approval / HITL

Outcome

Farmers get an accurate, spoken answer about their own collection entries and payment status in their own language at 5am or on the secretary's day off — grounded in the same MCU record and the same rate chart he would have read out.

Why it helps

The mechanism is language plus retrieval: the rate data is already in the MCU system and the chart is already published, but both are locked behind an English screen and one man's phone. Voice-first Indian-language access removes the literacy and availability barrier; routing disputes to a person keeps trust intact exactly where it matters.

Build spec

1 agent1 farmer-query agent. Speech in/out (Sarvam + ElevenLabs), the dispute branch, the payment Approval and the MCU lookup are workflow nodes, not extra agents.

System prompt (paste-ready)

You are a dairy union's farmer-support assistant for {{union}}. The farmer is identified by their calling number against the MCU register — never answer with another farmer's data, and if the number is unregistered, ask for the member code instead of guessing. Answer ONLY from the collection entries and payment status returned by the Tool (MCP) lookup and the published fat/SNF rate chart in Knowledge: state the quantity, fat, SNF, applied slab and rate for the date asked, and explain a rate difference by quoting the chart. Never estimate a rate, never promise a payment date beyond the documented cycle, and never state that a payment has been made unless the record says so. If the farmer disputes a quantity or a test result, or asks for an advance or an off-cycle payment, do NOT attempt to resolve it — acknowledge in their language and hand off for human review. Reply in the language the farmer used.

Agent roles & model tiers

  • Farmer query agent (per conversation) Economy tier — the highest-volume step in the whole dairy stack (every farmer, most mornings); a small model with a tight prompt and a real data lookup is both sufficient and the only affordable choice. A fallback model on a second provider keeps the morning rush answerable during an outage.

    Identify the farmer from the calling number, retrieve their real collection and payment records, and explain the rate in their own language using the published chart. No estimates, no payment promises, no cross-farmer data. Disputes and advance requests are handed off, not resolved.

MCP connectors

  • MCU / milk-collection unit software — via Tool (MCP): look up a member's collection entries for a date (quantity, fat, SNF, applied slab, rate) by member code
  • Procurement & payout ERP — via Tool (MCP): read the member's payment-cycle status and last settled cycle; the release call itself is only ever invoked after the Approval node
  • WhatsApp / Voice / SMS — the farmer's own channel
  • Razorpay UPI — payout reference returned to the farmer, only after a human releases the payment

Built-in tools

  • knowledge_search (scoped Knowledge collection: published fat/SNF rate chart + payment-cycle policy)
  • http_request (look up the farmer's collection entries and payment status by member code)
  • user-defined tool `rate_line_local` (SpEL, sandboxed formula — no API calls, no code): input.qtyL + ' L · FAT ' + input.fat + ' · SNF ' + input.snf + ' · ₹' + (input.qtyL * input.ratePerL) — formats the union's own rate line in one fixed shape for the SMS and the spoken reply
  • user-defined tool `payment_status_label` (SpEL): input.paidOn != null ? 'PAID' : (input.cycleClosed ? 'IN_SETTLEMENT' : 'CYCLE_OPEN') — a status label from the record's own fields; it reports state, it never triggers a payment

Guardrails

  • Identity is bound to the registered calling number — an unrecognised number is asked for a member code and never served speculative data; no farmer can be shown another farmer's entries
  • Every payment action — release, advance, correction — passes the Approval node. The agent explains payments; it never initiates one, and the `payment_status_label` expression only labels what the record already says
  • Rates and rate explanations are quoted from the published chart in the scoped Knowledge collection; the agent never computes a rate the chart does not support and never forecasts tomorrow's rate
  • Disputes over recorded quantity or test results are escalated to a person by design, not argued with — a disputed fat reading is a relationship issue, not a chatbot's call
  • The reply language mirrors the farmer's; a low-confidence transcription asks for a repeat rather than answering the wrong question confidently

Cost strategy

This is the volume workflow of the whole dairy stack, so tier discipline is the entire game: one economy-tier agent call per conversation, plus the Sarvam and ElevenLabs speech legs, which are usage-billed per audio minute and are the real variable cost — keep spoken replies short and factual rather than chatty. No batch multiplier and no case for a premium model here; correctness comes from the MCU lookup and the rate chart, not from model size. A fallback model matters more than a bigger one, because the 5am rush is unforgiving.

Output & delivery

The farmer's voice note or call is transcribed by Sarvam → the agent identifies them by number, pulls the real collection and payment record via Tool (MCP) and explains the rate from the published chart → the Condition node routes disputes and advance requests to a person, and any payment passes the Approval node → an Output node answers in the farmer's own language, spoken back via ElevenLabs on voice channels, with the Razorpay UPI reference attached once a human has released a payout. The union owns the reply format: `rate_line_local` is a formula the secretary's office can edit when the slab structure changes, without a developer or a redeploy.

3. Poultry shed mortality & environment alert → vet escalation

Today: the shed supervisor walks the litter each morning, counts the dead birds into a bucket, and writes the number in a ruled notebook next to the feed and water figures. The environment is a wall thermometer and whether the ammonia stings your eyes at the door. The notebook is typed into a spreadsheet weekly, which is when a rise finally becomes visible as a shape — by then the flock is days past the point where the visiting vet's early call would have changed anything. Day one of a real problem and an ordinary bad day look identical in a notebook.

Trigger: Device (shed environment sensors) + Webhook (daily flock/mortality record)

How the workflow runs

  1. Trigger

    Daily flock record lands. A Webhook carries the day's mortality count, feed and water intake per shed from the farm-management system (no first-party connector), alongside a Device Control node reading the shed's temperature, humidity and ammonia sensors.

  2. Parallel

    Read the two signals together. A Parallel node gathers the flock record and the environment series at the same time, so the analysis sees a mortality rise next to the shed conditions that preceded it — the comparison the notebook and the wall thermometer can never make.

  3. Agent

    Detect a deviation worth a vet's attention. An Agent node compares the day's figures against the flock's own recent baseline and the breed/age norms in a scoped Knowledge collection, and returns a structured finding: deviation size, direction, which signals moved together, and whether the environment record offers a candidate explanation.

  4. Condition

    Within normal variation?. A Condition node holds back ordinary day-to-day noise so the alert channel stays worth reading, and promotes anything crossing the documented deviation threshold — or any sustained multi-day drift — to escalation.

  5. Agent

    Brief the vet. A second agent writes a short veterinary briefing: shed, flock age, the trend series, feed/water divergence, environment readings, and the specific observations a stockman should collect on the ground. It describes; it does not diagnose and it never names a treatment.

  6. Approval

    Vet decides the response. An Approval node routes the briefing to the supervising veterinarian. Any intervention — a visit, sampling, a movement restriction, a culling decision — is the vet's call, made on the evidence, not the workflow's.

  7. Output

    Reach the farm in its own language. An Output node sends the check-list to the farm supervisor on WhatsApp with a Sarvam-generated local-language version and, on request, an ElevenLabs voice note — because the man walking the litter is not reading an English PDF. A Tool (MCP) node logs the alert and its outcome against the flock record.

Channels & connectors

  • Device Control (shed sensors)
  • Webhook
  • WhatsApp
  • Voice/Call
  • Sarvam (Indian languages)
  • ElevenLabs (voice)
  • Tool (MCP → farm-management system)
  • Approval / HITL

Outcome

Mortality and intake deviations are compared against the flock's own baseline on the day they appear — not in next week's spreadsheet — and reach the vet as a structured briefing with the shed conditions already attached.

Why it helps

The mechanism is early, consistent comparison: the daily numbers are already collected but only compared properly once a week, and never against the environment record at all. Running that comparison every day, the same way, moves a veterinary decision earlier — while the diagnosis and the intervention stay entirely with the vet.

Build spec

2 agents1 deviation-detection agent (per shed, per day) + 1 briefing agent (only on escalation). The Parallel gather, the noise gate, the vet Approval and the log write are workflow nodes. · Pattern: Parallel signal gather → detection → threshold gate → briefing → veterinary Approval

System prompt (paste-ready)

(Detection) Compare ONE shed-day against its own recent baseline and the breed/age norms in Knowledge. Inputs: {shed_id, flock_age_days, mortality_today, mortality_baseline[], feed_kg, water_l, intake_baseline[], env_series[{ts, temp_c, humidity_pct, ammonia_ppm}]}. Return strict JSON {deviation_pct, direction, signals_moved_together[], env_candidate_factor|null, sustained_days, band (NORMAL|WATCH|ESCALATE), evidence_note}. Use only the supplied series — never fill a missing day with an assumed value; a gap makes the band WATCH with the gap named. You do NOT diagnose disease, name a pathogen, or suggest any treatment or medication. Detection and description only.

Agent roles & model tiers

  • Deviation detection (per shed, per day) Economy tier — one call per shed per day across the whole farm, on mostly-normal data; the volume lives here, so the cheap tier does too, with a fallback model so a provider outage does not silently skip a day

    Compare one shed-day to its own baseline and the breed/age norms, return a strict-JSON deviation finding with a band. Gaps are WATCH, never NORMAL. No diagnosis, no pathogen names, no treatment.
  • Veterinary briefing (only when escalated) Standard tier — this is the one output a vet reads, and it must be clear, ordered and complete; rare enough that the better model costs almost nothing in aggregate

    Write a concise veterinary briefing from the escalated finding: shed, flock age, trend series, feed/water divergence, environment readings, and the specific on-the-ground observations a stockman should collect. Describe the evidence and list what to check. Do NOT offer a differential diagnosis, name a medication, or recommend culling — the vet decides.

MCP connectors

  • Farm / flock-management system — via Tool (MCP): pull the shed's daily mortality, feed and water series for the baseline window (inbound day record arrives by Webhook)
  • Shed environment sensor gateway — via Device Control, then Tool (MCP): read the temperature, humidity and ammonia series for the same window
  • Farm/flock-management system — via Tool (MCP): log the alert, its band and the vet's recorded outcome against the flock
  • WhatsApp / Voice — farm supervisor and stockman check-list, in the local language

Built-in tools

  • knowledge_search (scoped Knowledge collection: breed/age mortality and intake norms, deviation thresholds, biosecurity SOP)
  • http_request (pull the flock record; log the alert and its outcome)
  • user-defined tool `mortality_per_mille` (SpEL, sandboxed formula — no API calls, no code): (input.deathsToday * 1000.0) / input.birdsAlive — one arithmetic definition of the farm's own rate, used identically by every shed so the numbers are comparable
  • user-defined tool `shed_alert_band` (SpEL): input.perMille > input.escalatePerMille ? 'ESCALATE' : (input.perMille > input.watchPerMille ? 'WATCH' : 'NORMAL') — the farm's OWN thresholds, edited in the tool editor when the breed or the season changes; it bands for routing and never diagnoses anything

Guardrails

  • ANIMAL HEALTH: no agent diagnoses. Neither agent may name a disease, suggest a medication, or recommend culling — they quantify a deviation and describe the evidence; the supervising veterinarian decides at the Approval node
  • The `shed_alert_band` tenant expression is a routing classifier only. 'NORMAL' means 'do not page the vet today', never 'the flock is healthy'
  • Missing or partial daily records produce a WATCH with the gap named, never a NORMAL — an unrecorded day is missing evidence, not a good day
  • Deviation bands come from the documented breed/age norms in the scoped Knowledge collection, not from the model's own sense of what looks high
  • The noise gate is deliberate: only documented-threshold deviations and sustained drifts escalate, so the vet's alert channel keeps its signal and stays read
  • Alerts are idempotent per shed per day — a resent flock record updates the day's finding rather than re-paging the vet

Cost strategy

The detection pass runs once per shed per day forever, so it belongs on the economy tier with a hard cap — on a normal day that is the entire cost of the workflow, and the per-mille arithmetic is done by a SpEL expression rather than by tokens. The standard-tier briefing agent only ever runs on the small fraction of shed-days that clear the threshold gate: rare calls, high-value output, read by a veterinarian. Both roles carry a fallback model, since a skipped day is a lost signal you cannot recover later.

Output & delivery

The Parallel node gathers the flock record and the shed's environment series → the tenant's `mortality_per_mille` and `shed_alert_band` expressions turn raw counts into the farm's own comparable rate and band → the economy-tier detector reasons about the deviation against baseline → the Condition node's noise gate suppresses ordinary variation → on escalation the briefing agent writes a structured case → the veterinarian decides at the Approval node → an Output node sends the on-the-ground check-list to the farm supervisor on WhatsApp in the local language (Sarvam, with an ElevenLabs voice note on request) and a Tool (MCP) node logs the alert and its outcome.

4. Lab result → batch hold, with the release decision left to a human

Today: the platform and lab results come back on a printed sheet hours after the milk has moved on — adulteration screen, antibiotic residue, SPC. The quality chemist walks the sheet to the production manager, and the two of them stand at a screen working backwards: which tanker, which silo, which processing run, which pack codes, which of those went out on last night's dispatch. It takes three systems, a dispatch register and several phone calls, done under time pressure, and the branch somebody forgets is the branch that reaches a distributor.

Trigger: Webhook (lab/LIMS result posted against a batch)

How the workflow runs

  1. Trigger

    A result lands against a batch. A Webhook from the lab/quality LIMS (no first-party connector) delivers the result — test type, batch or tanker id, value, and the specification limit it was measured against.

  2. Condition

    Within specification?. A Condition node compares the value to the documented spec. In-spec results are logged and the flow ends; anything out of spec, borderline, or missing a value proceeds to the trace — a missing result is treated as out of spec, not as a pass.

  3. Supervisor

    Supervisor coordinates the trace across three systems. The genealogy lives in the MCU, processing and dispatch systems, each with its own shape. A Supervisor node delegates to a retrieval worker per system and holds the partial picture together, so no branch is dropped because one system answered awkwardly.

  4. Agent

    Retrieval worker walks its own system. Each worker run resolves one hop — collection lots feeding the batch, the silo and processing runs it joined, the finished pack codes and the consignments already dispatched — and reports every link it found plus every point where the chain broke.

  5. Agent

    Assemble the hold case. A case-writer agent turns the assembled genealogy into the document a quality head decides on: what was found against which limit, the traced scope upstream and downstream, which consignments have already left the plant, the affected farmers and centres, and the SOP's options — hold, re-test, divert, recall — with the condition attached to each.

  6. Approval

    Quality head decides hold, recall or release. An Approval node puts the decision in front of the quality head. Placing a hold, ordering a recall, and — critically — releasing a lot as fit are all human decisions. The workflow will never mark a batch safe.

  7. Output

    Execute the approved decision only. On approval, a Tool (MCP) node writes the hold or release status to the quality and dispatch systems, an Output node notifies plant, dispatch and (where the decision requires it) the affected distributors by WhatsApp and Email, and the full evidence trail is stamped to the batch id.

Channels & connectors

  • Webhook
  • Tool (MCP → lab/LIMS, MCU, processing & dispatch systems)
  • WhatsApp
  • Email
  • Approval / HITL
  • Knowledge base

Outcome

An out-of-spec result becomes a fully traced hold case — upstream lots, downstream packs, consignments already on the road — in front of the quality head in minutes, instead of two people reconstructing it across three screens and a dispatch register.

Why it helps

The mechanism is traversal speed and completeness: the batch genealogy exists across the MCU, processing and dispatch systems, but walking it by hand is slow and misses branches under exactly the pressure that makes missing one likely. Automating the traversal widens the evidence; hard-gating the release keeps the food-safety call where regulation and common sense both put it.

Build spec

3 agents1 supervisor + 1 retrieval worker (invoked once per source system by the Supervisor node) + 1 case-writer. The spec gate, the quality-head Approval and the status write-back are workflow nodes. · Pattern: Spec gate → Supervisor-coordinated multi-system trace → case assembly → quality-head Approval → gated execution

System prompt (paste-ready)

(Retrieval worker) Resolve ONE hop of a batch genealogy in ONE source system. Inputs: {batch_id, system (MCU|PROCESSING|DISPATCH), known_ids[]}. Return strict JSON {system, links[{from_id, to_id, kind, timestamp, detail}], trace_gaps[{id, reason}]}. Follow only links the system actually returns — never infer that a pack 'probably' came from this batch, never omit a branch because it looks unlikely, and never merge two ids because they look similar. Anything the system cannot resolve goes to trace_gaps with the reason. You do NOT judge whether the product is safe and you do NOT propose a disposition.

Agent roles & model tiers

  • Trace supervisor (once per flagged batch) Standard tier — decides which system to query next and when the picture is complete; a missed branch is the entire failure mode of this workflow

    Coordinate the trace: delegate one retrieval task per source system, feed resolved ids forward as the next hop's input, and keep going until no unresolved id remains or the system reports a gap. Never fill a gap yourself and never declare the trace complete while trace_gaps is non-empty — report it as incomplete instead.
  • Retrieval worker (once per source system) Standard tier — structured multi-hop retrieval where a quietly dropped link is invisible until a recall; deliberately NOT economised

    Resolve one hop in one system into strict JSON links plus an explicit trace_gaps list. No inference, no id merging, no omission, no safety judgement.
  • Hold-case writer (once per flagged batch) Premium tier — this document is read under time pressure by the person who signs the decision, and it is one call per incident; clarity and completeness are worth the tier here

    Write the hold case: the finding against its limit, the traced upstream and downstream scope, consignments already dispatched, affected farmers and centres, trace gaps, and the SOP's options (hold / re-test / divert / recall) with the condition attached to each. Present options and evidence. Never state or imply that the lot is safe, and never pick the option yourself.

MCP connectors

  • Lab / quality LIMS — inbound via Webhook, then Tool (MCP): fetch the full result set and the specification limit for the batch
  • MCU / milk-collection system — via Tool (MCP): resolve the collection lots, centres and farmer ids feeding the flagged batch
  • Processing / plant system — via Tool (MCP): resolve the silo and processing runs the batch joined, and the finished pack codes produced
  • Dispatch / distribution system — via Tool (MCP): list the consignments carrying those pack codes with their dispatch time and destination, and write the approved hold or release status
  • WhatsApp / Email — plant, dispatch and distributor notification per the SOP's notification matrix

Built-in tools

  • knowledge_search (scoped Knowledge collection: specification limits, batch-hold and recall SOP, notification matrix)
  • http_request (walk the genealogy across the three systems; write the approved hold or release status)
  • send_email (dispatch the approved notification to distributors on the SOP's matrix)
  • user-defined tool `spec_band` (SpEL, sandboxed formula — no API calls, no code): input.value == null ? 'NO_RESULT' : (input.value > input.limit ? 'OVER' : (input.value > input.limit * 0.9 ? 'NEAR_LIMIT' : 'WITHIN_LIMIT')) — the plant's own banding for ROUTING; 'WITHIN_LIMIT' opens no case, it does not release a lot

Guardrails

  • FOOD SAFETY, absolute: no agent and no tenant expression may release a batch or describe it as safe. Hold, recall and release are human decisions taken at the Approval node, and the evidence that justified each is stamped to the batch id
  • `spec_band` classifies a number against a limit for routing only — 'WITHIN_LIMIT' means the workflow does not open a hold case; the release of a lot is a separate, human, approved act
  • A missing, void or borderline result is handled as out of specification and proceeds to the trace — the absence of a result is never a pass
  • The trace reports only links the source systems actually return; every broken or ambiguous link is surfaced in trace_gaps, and the supervisor may not declare a trace complete while gaps remain — an incomplete trace is stated as incomplete
  • Spec limits, options and the notification matrix come from the documented SOP in the scoped Knowledge collection; the agent never sets or relaxes a limit
  • No status is written and no distributor is notified before approval — the write-back path is unreachable without the human decision, and it is idempotent per batch id

Cost strategy

This workflow runs rarely — only on out-of-spec, borderline or missing results — and each run carries real consequence, so the retrieval roles sit on the standard tier with a generous tool-call budget and the single case-writing call is allowed the premium tier. The economy tier is deliberately absent here: the cost of a missed downstream branch dwarfs any token bill. Volume control comes from the `spec_band` routing gate in front, not from shrinking the model. Fallback models are configured on all three roles, because a provider outage during a hold decision is not an acceptable delay.

Output & delivery

The Condition node gates on specification (missing counts as out) → the Supervisor node coordinates retrieval workers across the MCU, processing and dispatch systems until no id is unresolved → the premium-tier case-writer assembles the evidence, the trace gaps and the SOP's options → the quality head decides hold, re-test, divert, recall or release at the Approval node → only then does a Tool (MCP) node write the status and send_email notify distributors per the SOP matrix, with the full trail stamped to the batch.

Related industries

Build one of these in minutes

The sandbox gives you a live agent workspace — no account, no card. Or head back to the full catalogue and compare patterns across every industry.

See how VegaDūta compares to n8n, Dify and BotpressWhy VegaDūta's architectureEstimate your WhatsApp API costs