Sizing the Failover Budget When the Agent Driving Your HiL Rig Stops Answering
In an agentic hardware-in-the-loop bench, the real-time target can't wait for the agent. The LLM planner runs behind the Model Context Protocol inside a WebAssembly sandbox, so it can stall, crash or produce stimulus outside the envelope, and the silicon under test still needs a valid input on every step. The sizing question is whether the supervisor can detect the fault and switch to a safe stimulus source inside one plant step. Everything below follows one calculation through to that answer, and every figure in it is an estimate you should replace with your own measurements.
The model and its single governing inequality
Take a nominal plant model step, T_step, of 1 ms as the working estimate, which is typical for a powertrain or motor control loop closed through the bench. Missed frames come out as N_missed = ceil((t_detect + t_switch) / T_step), where t_detect is the time from the agent's last valid output to the supervisor declaring it dead, and t_switch is the time to route the stimulus multiplexer to a last-known-good vector table. The design goal is N_missed equal to zero, which means the real-time core must never sample a stale or undefined value. That puts a hard condition on the system: t_detect + t_switch has to fit inside the slack between the agent's write deadline and the target's sampling instant, not inside the whole step. People tend to budget against the full step, then discover that the slack was really a fraction of it.
Carrying the numbers through
With a software supervisor on an isolated real-time core, polling a heartbeat the sandbox writes once per step and switching through a memory-mapped multiplexer, my working estimate for t_detect + t_switch is 0.4 ms, with an error bar of plus or minus 0.15 ms that covers cache misses, interrupt latency and the cost of one sandbox trap. The upper bound of that estimate leaves a worst-case margin of roughly 0.45 ms against the 1 ms step, also an estimate. That margin looks comfortable until you subtract the agent's own write window, because the supervisor only gets to act in the part of the step after the agent should have delivered. If the agent normally writes in the first half of the step, the effective slack shrinks to about half the step, and the upper bound of the detect and switch estimate eats most of it. The model says it fits. The error bar says it fits with almost nothing to spare.
The failure mode that breaks the arithmetic
The calculation assumes the supervisor and the agent fail independently. The usual way that assumption breaks is a common-cause fault: the watchdog thread shares a core, a clock domain or a memory controller with the WebAssembly runtime, so a runaway allocation or a lock held during a trap freezes both at once, and the heartbeat goes quiet without anything left running to notice. Functional safety standards such as ISO 26262 and IEC 61508 deal with this through freedom from interference and diverse supervision, and for a test bench the same reasoning applies even if no certificate is involved. A supervisor that can be starved by the thing it supervises has an effective t_detect of infinity, and none of the previous section's numbers mean anything until you have shown the two can't block each other.
Decision rule: if the upper bound of your measured t_detect + t_switch exceeds half of the real slack after the agent's write window, or if you can't show the supervisor is independent of the sandbox in core, clock and memory path, move the watchdog and the stimulus multiplexer into FPGA fabric with its own oscillator. Accept the extra integration work and a vector table that has to be regenerated whenever the plant model changes.
Technical FAQ: Why not just give the agent a longer deadline and skip the hardware watchdog?
A longer deadline only moves the point where the agent's write is late. It doesn't remove the case where the agent never writes at all, so the target still samples an undefined input once per fault. The step period is set by the plant dynamics you are validating, and stretching it to fit the agent changes the test into something other than the one you meant to run.