<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:discourse="http://discourse.org/rss/modules/discourse/">
<channel>
<title>V12.0 on Roque</title>
<link>https://j-roque.com/tags/v12.0/</link>
<description>Recent content in V12.0 on Roque</description>
<generator>Hugo -- gohugo.io</generator>
<language>en</language>
<managingEditor>joao.roque.94@gmail.com (João Roque)</managingEditor>
<webMaster>joao.roque.94@gmail.com (João Roque)</webMaster>
<copyright>© 2026 João Roque</copyright>
<lastBuildDate>Wed, 25 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://j-roque.com/tags/v12.0/index.xml" rel="self" type="application/rss+xml"/>
<item>
<title>Human in the Loop for MES Agents: Notifications, a Respond Wizard and Reruns with the Answers</title>
<link>https://j-roque.com/posts/20261125-humanintheloop/</link>
<pubDate>Wed, 25 Nov 2026 00:00:00 +0000</pubDate>
<author>joao.roque.94@gmail.com (João Roque)</author>
<guid>https://j-roque.com/posts/20261125-humanintheloop/</guid>
<description>Last time the agent mapped equipment files to a Data Collection and sent the doubtful ones to a human. This post builds that human part: a notification with the agent&amp;rsquo;s open questions, a chat-style Respond wizard, request/reply delivery over the message bus, and a single Run Agent task that replaces the code tasks and the second workflow of the first version.</description>
<content:encoded>&lt;p&gt;&lt;img src="https://j-roque.com/posts/20261125-humanintheloop/featured.png" alt="Human in the Loop for MES Agents: Notifications, a Respond Wizard and Reruns with the Answers" /&gt;&lt;/p&gt;&lt;p&gt;Agents are probabilistic machines, it&amp;rsquo;s best to give them an escape hatch for low confidence scenarios to ask a human than to make bad decisions.&lt;/p&gt;
&lt;p&gt;Last week&amp;rsquo;s agent returns &lt;code&gt;needs_review&lt;/code&gt; when it is unsure. This post shows what happens next, from the notification to the person&amp;rsquo;s answer and the agent&amp;rsquo;s second run.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="Human in the loop"
src="https://image.j-roque.com/posts/20261125-humanintheloop/hil.gif"
&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 class="relative group"&gt;Overview
&lt;/h2&gt;
&lt;p&gt;In &lt;a
href="https://j-roque.com/posts/20261118-agenticframework/"
target="_blank"
&gt;the previous post&lt;/a&gt; a &lt;code&gt;Connect IoT&lt;/code&gt; workflow read equipment files, a &amp;ldquo;File Parser for DataCollection&amp;rdquo; agent mapped them to a Data Collection, and a guard clause routed the answer to &lt;code&gt;ok&lt;/code&gt;, &lt;code&gt;needs_review&lt;/code&gt; or &lt;code&gt;rejected&lt;/code&gt;. &lt;code&gt;needs_review&lt;/code&gt; went &amp;ldquo;to a human&amp;rdquo;. In this blog post we will chart that flow, the human-in-the-loop.&lt;/p&gt;
&lt;p&gt;It was built with the agentic process from &lt;a
href="https://j-roque.com/posts/20261116-orca-agentic-mes/"
target="_blank"
&gt;Orca, Worktrees and the First Iteration of an Agentic MES Project&lt;/a&gt;, trust me I can&amp;rsquo;t code UIs if my life depended on it, and the walkthrough below is one run on a local MES v12 stack: one ambiguous file, the real agent, two rounds of answers.&lt;/p&gt;
&lt;h2 class="relative group"&gt;An Ambiguous File
&lt;/h2&gt;
&lt;p&gt;The test case is a rework re-inspection of housing &lt;code&gt;A12&lt;/code&gt;, serial &lt;code&gt;SN-0042822&lt;/code&gt;. The file is ambiguous in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hole A appears twice: &lt;code&gt;12.024&lt;/code&gt; as found with burr, and &lt;code&gt;12.013&lt;/code&gt; re-measured after deburring.&lt;/li&gt;
&lt;li&gt;Roundness &lt;code&gt;4.6&lt;/code&gt; and flatness &lt;code&gt;22&lt;/code&gt; were read with dial indicator &lt;code&gt;DI-2&lt;/code&gt;, and nobody recorded its unit.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A parser would pick one. The agent returns &lt;code&gt;needs_review&lt;/code&gt; with open questions instead. Remember, the goal is to be able to extract information and adapt to any kind of file content as long as it contains the needed information.&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-bash"&gt;REWORK STATION RW-2 - MANUAL RE-INSPECTION LOG
Part: A12-HSG-0007    S/N: SN-0042822    Date: 18.11.2026 14:05
Inspector: OP03       Reason: burr found on hole A at line QC, part sent to rework
Instruments: bore gauge BG-12 / BG-08 (mm), height gauge HG-1 (mm),
             dial indicator DI-2 (unit setting not recorded), calliper CS-200 (mm)
Hole A dia ........... 12.024   (as found, burr present)
Hole A dia ........... 12.013   (re-measured after deburr)
Hole B dia ...........  7.996
Pitch A-B ............ 41.995
TP hole B ............  0.027
Roundness hole A .....  4.6     DI-2
Top face flat ........ 22       DI-2
Top face // base .....  0.012
Length ............... 84.488
Width ................ 32.009
Ra sealing face (2 traces): 0.86 / 0.90 um
Hall temp. approx. 21 C
Remarks: DI-2 readings copied from the old paper sheet, units to be checked.
Part released back to the line after rework - OP03&lt;/code&gt;&lt;/pre&gt;
&lt;h2 class="relative group"&gt;Building on what the MES ships with
&lt;/h2&gt;
&lt;p&gt;To create the request flow we leverage the standard MES Notification.&lt;/p&gt;
&lt;p&gt;We create a new type, &lt;code&gt;HumanInTheLoopNotify&lt;/code&gt;, named &lt;code&gt;HITL-&amp;lt;GUID&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The GUID is the correlation id, as the name implies it allows us to track the same interaction along multiple iterations: in iot the &lt;code&gt;Run Agent&lt;/code&gt; task keeps the request under that id in its persistent store until someone answers.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Title&lt;/strong&gt; is readable (&amp;ldquo;Review needed: DC_Housing_A12_FullInspection – no material&amp;rdquo;), and the Details are a meaningful description: why a review is needed, the open questions, what is missing, the agent&amp;rsquo;s notes, the Data Collection and what to do.&lt;/p&gt;
&lt;p&gt;The full agent response and the original prompt live in a payload attribute. An attribute value holds at most 512 characters, so the payload is chunked and shown as two tiles, &lt;em&gt;Agent Feedback&lt;/em&gt; (information from the agent) and &lt;em&gt;Original Prompt&lt;/em&gt; (information provided to the agent), among the stock notification Details tiles.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="The HITL notification"
src="https://image.j-roque.com/posts/20261125-humanintheloop/notification-details.png"
&gt;&lt;/figure&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;em&gt;The notification page: Respond in the ribbon, the agent&amp;rsquo;s two open questions, and the Original Prompt and Agent Feedback tiles.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;This needs &lt;strong&gt;no new entity&lt;/strong&gt; or page, because Notifications already have assignment, a side panel, history and clearing. Just leveraging the existing framework.&lt;/p&gt;
&lt;h2 class="relative group"&gt;The Respond Wizard Is a Conversation
&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Respond&lt;/strong&gt; is a custom action on the Notification page and in the notifications side panel. It opens a chat like wizard.&lt;/p&gt;
&lt;p&gt;Each agent request is a formatted bubble. Each answer is a blue bubble with who sent it and when. All of it is rebuilt from the notification&amp;rsquo;s standard MES history, so there is no extra storage.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="Respond wizard, round 1"
src="https://image.j-roque.com/posts/20261125-humanintheloop/respond-round1.png"
&gt;&lt;/figure&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;em&gt;Round 1: the agent&amp;rsquo;s request as the first bubble, an answer box, and three outcomes.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The three outcomes:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Button&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Answer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Sends the text, keeps the notification open, the agent runs again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Submit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Accepts the agent&amp;rsquo;s current result as it is&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Discard&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Ends the request, after a confirmation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The first bubble is the agent output of the analysis of the file. We can now start the conversation loop.&lt;/p&gt;
&lt;p&gt;Here is the answer for round 1 before it is sent:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="Answer typed in the wizard"
src="https://image.j-roque.com/posts/20261125-humanintheloop/answer-typed.png"
&gt;&lt;/figure&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;em&gt;A person answers the way they would answer a colleague.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 class="relative group"&gt;Using the MES Out of the Box Gateway
&lt;/h2&gt;
&lt;p&gt;Leveraging the send request message bus, we can make sure to only block the buttons if we have an acknowledge that the message is not just sent but received.&lt;/p&gt;
&lt;p&gt;A DEE business rule on the notification save sends the outcome over the MES message bus as a &lt;strong&gt;request&lt;/strong&gt; to the subject &lt;code&gt;&amp;lt;base topic&amp;gt;.&amp;lt;GUID&amp;gt;&lt;/code&gt;, and saves the answer only when the requester replies &lt;code&gt;{&amp;quot;status&amp;quot;:&amp;quot;ack&amp;quot;}&lt;/code&gt; within 30 seconds. Without the acknowledgement, the message shows in red with the requester&amp;rsquo;s error and a &lt;strong&gt;Resend&lt;/strong&gt; button.&lt;/p&gt;
&lt;p&gt;After an acknowledged answer the notification stays open. The title gets the prefix &amp;ldquo;Waiting for agent reply:&amp;rdquo;, the buttons are disabled, the answer box is hidden and the wizard refreshes itself until the agent answers.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="Waiting for the agent"
src="https://image.j-roque.com/posts/20261125-humanintheloop/answer-waiting.png"
&gt;&lt;/figure&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;em&gt;Answer acknowledged: the blue bubble with the author and time, &amp;ldquo;Waiting for the agent&amp;rsquo;s reply…&amp;rdquo;, buttons disabled.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 class="relative group"&gt;The Agent Runs Again with the Whole Conversation
&lt;/h2&gt;
&lt;p&gt;The agent is stateless, so the task gives it everything: the original prompt plus a &lt;code&gt;review&lt;/code&gt; object with the round, the previous result and every answer so far.&lt;/p&gt;
&lt;p&gt;If the new result still needs review, the &lt;strong&gt;same&lt;/strong&gt; notification is updated: the title becomes &amp;ldquo;Review needed (round 2): …&amp;rdquo;, the outcome resets, and the conversation shows round 1 request, answer, round 2 request.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="Round 2 of the conversation"
src="https://image.j-roque.com/posts/20261125-humanintheloop/conversation-round2.png"
&gt;&lt;/figure&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;em&gt;The end of the round 1 request, the blue answer, and the round 2 request.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In the live run, the round 1 answer was &lt;em&gt;&amp;ldquo;Hole A is Bore D1. Post BoreDiameter1 = 12.013, the value re-measured after deburring; ignore 12.024&amp;rdquo;&lt;/em&gt;. The agent took it and asked about the unit of &lt;code&gt;DI-2&lt;/code&gt;. The round 2 answer was &lt;em&gt;&amp;ldquo;DI-2 was set to µm: BoreD1Roundness = 0.0046 mm and Flatness = 0.022 mm&amp;rdquo;&lt;/em&gt;, plus the remaining confirmations.&lt;/p&gt;
&lt;p&gt;Then the result was accepted and the notification cleared itself. The Data Collection instance &lt;code&gt;DC_Housing_A12_FullInspection-000000007&lt;/code&gt; was posted with &lt;code&gt;BoreDiameter1 = 12.013&lt;/code&gt; and &lt;code&gt;Bore D1 Roundness = 0.0046&lt;/code&gt;. Both values come accurately based on the answer from the human in the loop.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="The posted Data Collection instance"
src="https://image.j-roque.com/posts/20261125-humanintheloop/dc-instance-data.png"
&gt;&lt;/figure&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;em&gt;The posted instance: Bore D1 Diameter 12.013 and Bore D1 Roundness 0.0046.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 class="relative group"&gt;Guard Clause tab
&lt;/h3&gt;
&lt;p&gt;Last week, we showed a code task performing our guard clause. Actually, this such a common scenario that we decided to make that part of our runAgent Connect IoT task. The code-task guard from last week is now three JSON Schemas, validated with &lt;code&gt;ajv&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Response Schema&lt;/strong&gt;: the shape every response must have. If it does not match, the result is Rejected with &amp;ldquo;Invalid agent response: …&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reject Schema&lt;/strong&gt;: for example &lt;code&gt;status = error&lt;/code&gt;. Rejected, with the agent&amp;rsquo;s reason.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accept Schema&lt;/strong&gt;: &lt;code&gt;status&lt;/code&gt; is &lt;code&gt;ok&lt;/code&gt;, nothing is missing, every mapping has high confidence, there is some data. Accepted.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Anything valid that is not accepted needs review. Note that when we declared our agent we also specified a contract of what we would send as prompt and the format we expect as answer.&lt;/p&gt;
&lt;p&gt;The Accept Schema holds the old &lt;code&gt;effectiveStatus&lt;/code&gt; rules as data:&lt;/p&gt;
&lt;pre&gt;&lt;code class="language-json"&gt;{
  &amp;#34;type&amp;#34;: &amp;#34;object&amp;#34;,
  &amp;#34;required&amp;#34;: [&amp;#34;status&amp;#34;, &amp;#34;rawData&amp;#34;, &amp;#34;mappings&amp;#34;, &amp;#34;missing&amp;#34;],
  &amp;#34;properties&amp;#34;: {
    &amp;#34;status&amp;#34;: { &amp;#34;const&amp;#34;: &amp;#34;ok&amp;#34; },
    &amp;#34;missing&amp;#34;: { &amp;#34;type&amp;#34;: &amp;#34;array&amp;#34;, &amp;#34;maxItems&amp;#34;: 0 },
    &amp;#34;mappings&amp;#34;: { &amp;#34;type&amp;#34;: &amp;#34;array&amp;#34;, &amp;#34;items&amp;#34;: { &amp;#34;properties&amp;#34;: { &amp;#34;confidence&amp;#34;: { &amp;#34;const&amp;#34;: &amp;#34;high&amp;#34; } } } },
    &amp;#34;rawData&amp;#34;: { &amp;#34;type&amp;#34;: &amp;#34;object&amp;#34;, &amp;#34;minProperties&amp;#34;: 1 }
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The rules of the guard are now a task setting that a process engineer can read and change without a code deploy.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="Guard Clause settings"
src="https://image.j-roque.com/posts/20261125-humanintheloop/settings-guard-clause.png"
&gt;&lt;/figure&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;em&gt;Guard Clause tab: the toggle and the three schema editors.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 class="relative group"&gt;Human In The Loop tab
&lt;/h3&gt;
&lt;p&gt;The human in the loop is similar to the guard clause, in the sense that it&amp;rsquo;s a common scenario that is part of running an agent. So we added it as a setting of the runAgent task.&lt;/p&gt;
&lt;p&gt;With it enabled, the task creates and updates the notification itself, subscribes once to &lt;code&gt;&amp;lt;base topic&amp;gt;.&amp;gt;&lt;/code&gt;, acknowledges, runs the agent again, clears on accept or reject, and treats Submit as &amp;ldquo;accept the reviewed result without running again&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Pending requests live in the controller&amp;rsquo;s persistent data store, so they survive a restart.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;&lt;figure&gt;&lt;img
class="my-0 rounded-md"
loading="lazy"
decoding="async"
fetchpriority="low"
alt="Human In The Loop settings"
src="https://image.j-roque.com/posts/20261125-humanintheloop/settings-human-in-the-loop.png"
&gt;&lt;/figure&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;em&gt;Human In The Loop tab: requester, notification type, assignment, base topic and store key.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;A &lt;code&gt;Prompt&lt;/code&gt; output emits the prompt the result belongs to. The Data Collection task takes its information and posts the data. This data can have been directly from the first agent reply or have passed cycles of human and agent interaction.&lt;/p&gt;
&lt;h2 class="relative group"&gt;Final Thoughts
&lt;/h2&gt;
&lt;p&gt;The MES is a toolbox and offers us a lot of pathways. In this blog post we leverage what are the MES guardrails like data collection parameters, with MES standard feature set like notifications and then joined them with the new agent framework.&lt;/p&gt;
&lt;p&gt;In the next post I&amp;rsquo;ll give the agent a memory across requests. With this post we ensure a healing flow, where an incomplete answer can be completed with human feedback, with the introduction of memory we will create a long lasting solution.&lt;/p&gt;
</content:encoded>
<enclosure url="https://j-roque.com/posts/20261125-humanintheloop/featured.png" type="image/png" length="0"/>
<media:content url="https://j-roque.com/posts/20261125-humanintheloop/featured.png" type="image/png" medium="image"/>
</item>
</channel>
</rss>