BenchForge for Hermes
The flight simulator for AI-written Arduino firmware. Proven on the chip before it touches the world.
The problem. People now ask AI to write the code for the small computer inside their gadgets: a greenhouse fan, a parking sensor, an egg incubator. The code compiles and looks right. Then it meets a real board. Cut one sensor wire and the fan relay clicks 40 times a second instead of failing safe, and the plants cook. After 49 days the board's clock wraps and the status light goes haywire. One button press counts as five. You find these bugs after the wiring is done, with mains power, a motor or a heater on the other end.
What BenchForge does. It puts that code through a driving test before it gets the keys:
- You approve the checks first, in plain English, before any code exists ("temp reads 32 °C → fan turns on within 1 s").
- Hermes writes the sketch, the real Arduino compiler builds it, and the firmware runs instruction by instruction on a simulated ATmega328P, the chip on an Arduino Uno, with simulated sensors, buttons, relays, servos and buzzers on its pins.
- Then come the crash tests: a noisy sensor, a wire cut mid-run, the clock wrapping, a bouncy button. Every failure goes back to Hermes, one at a time, until everything passes.
- The agent can't flash a real board with anything that hasn't passed. A Hermes hook checks every upload command against a proof receipt and blocks the rest.
You get the sketch, the firmware, an animation of the run, a link that replays it in any browser, and a receipt anyone can re-run.
▶ Try it in your browser, nothing to install · How to test · Seen working · Where to check each claim · How it works · Why it's a plugin, not a prompt · Questions · What works today
| No hardware needed | the chip, the sensors and the faults are all simulated |
| 5 golden benches, 10 sketches | every first draft fails exactly the checks it should; every fix passes; CI on Linux, macOS and Windows |
| A real agent, stopped | in a real Hermes gateway the agent tried to flash firmware nobody had approved, and the flash gate blocked it (run) |
| Installs the way a judge installs | hermes plugins install on clean Linux and macOS machines, then /bench demo to 22/22 (run) |
How To Test
No Arduino, no hardware, no wiring.
In 10 seconds, in your browser: open the live board. This is the greenhouse fan's first draft. It passes its normal checks, but its crash tests fail. Tap Try it yourself, drag the temperature slider past 30 °C, then tick cut the wire. The fan relay starts clicking 30 times a second. Now open the fixed firmware and do the same: the fan fails safe and stays on. Both are the real compiled firmware running on the simulated chip in your browser.
In two commands, without Hermes (Python 3.11+ and Node.js 18+):
git clone https://github.com/ohjay-official/hermes-benchforge && cd hermes-benchforge
python -m benchforge setup # once: the official arduino-cli and AVR core, SHA-256 pinned (~150 MB)
python -m benchforge demo # a greenhouse fan controller: first draft vs fixed
In Hermes:
hermes plugins install ohjay-official/hermes-benchforge --enable
hermes bench setup
Then, in any Hermes chat (CLI, Telegram, Discord, Slack):
/bench demo
/bench greenhouse fan: LM35 on A0, relay on D7 on above 30 °C and off below 27 °C, LED on D13 blinks every second
/bench demo starts from a typical first-draft sketch so you can watch the fix loop. A /bench <description> request starts from nothing. On Telegram, Hermes's own commands fill the command menu; hermes config set platforms.telegram.extra.command_menu.priority bench lists /bench first (typing it works either way).
Check a sketch of your own:
python -m benchforge check examples/greenhouse-fan/bench.json # the checks in plain English
python -m benchforge run examples/greenhouse-fan/bench.json my.ino # compile, simulate, judge
python -m benchforge verify <receipt.json> my.ino # rebuild, re-run, prove the receipt
Inside Hermes the same commands are hermes bench check|run|verify.
Seen Working
A real run on Telegram, on a phone, 9 November 2026: Hermes on gemini-3-flash-preview, BenchForge from this repo, nothing staged.
- Left:
/bench demoafter approval. The first sketch fails 3 of 23 checks. The model's first fix solves the clock bug but not the cut wire; its second makes things worse (16/22); its fourth gets every check green. Each 🔧 line is the model's own note on what it changed. BenchForge doesn't take its word for it: every round is compiled and re-run. - Middle: the animation that arrives with the result, plus a zip with the sketch, firmware, receipt and an offline live board.
- Right: asked to upload a sketch BenchForge never tested, the agent ran
arduino-cli upload, and the flash gate stopped it.
It doesn't always get there. One run that afternoon stopped at 21/23, the cut-wire test still failing, and reported itself not green; the gate stayed shut for that firmware. That's the point: nothing ships on the model's say-so.
Where To Check Each Claim
| Claim | Check it here |
|---|---|
| The firmware really runs on a simulated ATmega328P | engine/bench.js (the parts and faults), on avr8js; open the live board and cut the wire yourself |
| Every crash test catches a real bug | examples/*/expect.json and tools/golden.py, run by CI on three systems |
| The same firmware always gets the same result | python -m benchforge verify <receipt> <sketch> rebuilds and re-runs; CI requires an exact match |
| The model can't move the goalposts | checks are locked by hash at approval (benchforge/forge.py); the fixer is told to keep every threshold (benchforge/prompts.py); a receipt records the bench hash |
| The agent can't flash untested firmware | benchforge/gate.py, FlashGate tests, and the real-gateway run |
| It installs and works the way a judge would use it | judge path workflow and its run |
| It passes the catalog's own admission checks | hermes plugins validate (security scan: safe) and doctor, in the CI hermes plugin checks job |
| A sketch can't read your files while compiling | docs/SECURITY.md and tests/test_core.py SketchScanner |
What You See
python -m benchforge demo prints the bench, then runs both sketches:
The firmware passes only if:
1. at power-on → fan stays off for 1.5 s
2. temp reads 32 °C → fan turns on within 1 s
3. temp reads 28.5 °C → fan stays on for 2 s
4. temp reads 26 °C → fan turns off within 1 s
5. temp reads 29 °C → fan stays off for 2 s
6. temp reads 30.8 °C → fan turns on within 1 s
7. The whole time, led blinks at 1 Hz (±10 %)
8. If temp is unplugged → fan on (fail safe)
━━ First draft (draft.ino) ━━
❌ Not yet: 20/23 checks passed across 4 runs
✓ Your checks: 7/7
✓ Noisy sensor (temp ±0.6 °C): 7/7
✗ Clock rollover (millis() wraps at 3.7 s, as on day 49.7): 6/7
✗ the whole time, led blinks at 1 Hz (±10 %)
saw: led blinked at 333.33 Hz, unevenly (periods from 3 ms to 1 s)
✗ temp unplugged mid-run: 0/2
✗ temp unplugged → fan falls back to on within 2 s
saw: fan flickered between off and on 68 times
✗ fan never clicks more than 4 times a second
saw: fan clicked 40 times within one second, from 2.7 s
━━ After fixes (fixed.ino) ━━
✅ All green: 22/22 checks passed across 4 runs
The first draft passes every normal check, and most people would ship it. The crash tests catch two bugs:
- The heartbeat timer. It is written as
millis() >= next, which breaks the moment the clock wraps. - The cut sensor wire. A cut wire makes the reading jump around, and the fan relay clicks 40 times a second instead of failing safe.
In a chat, /bench shows the same thing live, as one message that updates itself:
✅ greenhouse-fan: checks approved and locked (bench e228f7e6043a).
🔌 Compiling and putting the sketch on the bench…
First sketch: ✗ 20/23
✗ Clock rollover: the whole time, led blinks at 1 Hz (±10 %)
saw: led blinked at 333.33 Hz, unevenly (periods from 3 ms to 1 s)
🔧 Switched to millis() subtraction and added a sensor-fault check that turns the fan on.
Fix 1: ✅ 22/22 checks pass
The 🔧 line is the model's own summary of its change. The reply then shows:
- the run as an animated GIF of the board (above)
- a zip with the sketch, the firmware (
.hex), the receipt andlive.html, which opens the live board offline with this firmware in it
The reply also carries a link straight to the live board with this firmware in it. A firmware is 3 to 5 KB, so links are compressed against a dictionary of the golden benches' own results and firmware (web/dicts/, built and checked in CI by tools/make_live_dict.py); most of any Uno firmware is the same Arduino core code, so a link comes out around 1 to 2.5 KB and fits in a Telegram message. Discord's 2,000 characters are too few, so there the reply points to live.html in the zip.
The live board runs the same engine in the browser, with the same simulated parts. Play the bench replays the exact test. Try it yourself gives you a slider for every sensor, a button you can hold, and a cut the wire switch for each sensor. The firmware travels in the link after #, which the browser never sends to the server; the page only fetches its own files (the engine and the link dictionary). A bundle zip opened on the page is read locally and never uploaded.
How It Works
"greenhouse fan…" → checks (plain English) → you approve → locked by SHA-256
│
┌──────────────── Hermes fixes one failure at a time ◄───────────┤
▼ │
sketch.ino → arduino-cli (sealed) → firmware.hex → simulated ATmega328P + parts
│
your checks, then the crash tests
│
all green → receipt → the flash gate opens for this exact .hex
- Checks first. The bench is JSON in a small fixed vocabulary: parts, pins, steps, expectations. BenchForge turns it into plain-English lines itself (the model never writes the wording you approve), and a model can't slip in anything the vocabulary doesn't have. On Telegram, Discord and Slack you approve with a button; elsewhere with
/bench approve <id>. - Real compiler. The sketch is compiled by arduino-cli 1.4.1 for
arduino:avr:uno(avr-gcc 7.3, LTO), the same build the Arduino IDE makes. It is first scanned and compiled alone in a sealed folder (why). - Real chip, simulated parts. The firmware runs on avr8js, the open-source AVR emulator behind Wokwi, at 16 MHz, one instruction at a time. The timers, interrupts, ADC, UART, EEPROM and watchdog are all emulated. BenchForge adds the parts:
- an LM35 at 10 mV/°C
- a 10k NTC thermistor in a divider
- a potentiometer
- a push button with pull-up
- an HC-SR04 that answers trigger pulses with echo pulses 58 µs/cm long
- LEDs, including PWM brightness
- relays (active-high or active-low)
- a buzzer, measured in Hz
- a servo, read from the pulse width
- Deterministic. There is no wall clock and no
Math.random. Sensor noise comes from a seeded generator, so the same firmware on the same bench gives the same result every time, which is what makes receipts provable. - Crash tests. The approved checks run again under conditions real boards meet (below).
- The fix loop. Hermes gets the earliest failure: what was expected, what happened, when, the last Serial lines, and a hint for crash-test failures. It returns a new sketch. This repeats up to 5 times, and stops early if the model repeats itself.
- Receipt and flash gate. A receipt records the bench, the sketch and firmware hashes, and every result. Its id is the hash of its contents. A
pre_tool_callhook blocks the agent from flashing any.hexthat lacks a passing, untampered receipt against checks a person approved.
The Crash Tests
| Test | What happens | The bug it catches |
|---|---|---|
| Noisy sensor | every ADC conversion jitters (±0.6 °C, ±1.5 %), so averaging really helps | no hysteresis or smoothing: relays chatter, servos twitch |
| Clock rollover | millis() and micros() start just short of their wrap, as on day 49.7, and wrap mid-test | millis() >= deadline timing, which breaks after 49.7 days of uptime. Timers must start from millis() in setup(), since the clock doesn't start at 0 here |
| Bouncy button | every press and release chatters for 5 ms | no debounce: one press counts several times |
| Unplugged sensor | the sensor wire is cut mid-run: the pin floats, or a divider pulls it to a rail | firmware that trusts garbage and drives outputs unsafely |
| Relay chatter (always on) | any relay that clicks more than 4 times in one second | fails in every run, crash test or not |
Why It's A Plugin, Not A Prompt
A prompt can say "I tested it". BenchForge actually runs the code:
- The real toolchain. It downloads and pins arduino-cli and the AVR core, and runs an instruction-level AVR emulator as a sandboxed Node.js process.
- Five Hermes surfaces, one core.
/benchusesctx.ask_choice(approval buttons),ctx.post_message(a live progress message it edits in place) andctx.llm(three separate model jobs: bench writer, coder, fixer).bench_guideandbench_testare tools, so the agent tests its own Arduino work in ordinary chats.- A
pre_tool_callhook is the flash gate. hermes benchcovers the terminal.- Everything also runs without Hermes, as
python -m benchforge.
- Separation of duties. The checks are written and approved before the code exists. The coder never sees the crash tests, and the fixer can't change the checks.
- Proof, not trust.
hermes bench verifyrebuilds the firmware from the sketch, re-runs the bench and compares every result with the receipt. CI does exactly this on every push.
Compared With The Usual Ways
| Ask a model for code | Test on a real board | BenchForge | |
|---|---|---|---|
| Finds the bug before the wiring is done | no | no | yes |
| Cut wires, 49-day clock wrap, button bounce | only if you think of them | only if you wait or break something | every run, automatically |
| Checks a person agreed to | no | in your head | yes, approved in plain English, locked by hash |
| Fixes itself | you paste errors back | you debug | Hermes fixes until green, up to 5 rounds |
| Stops the agent flashing untested code | no | no | yes, the flash gate |
| Proof someone else can re-run | no | no | a receipt, hermes bench verify |
Questions People Ask
Do I need an Arduino? No. Everything runs on the simulated chip. You only need a board when you flash the result.
Is a simulator good enough? For the logic, yes; that's where these bugs live. The chip is emulated instruction by instruction, with its real timers, interrupts and ADC, running the exact firmware the Arduino compiler made. The parts are idealised (an LM35 is a perfect 10 mV/°C), so BenchForge proves the firmware handles the cases on the bench, not that your wiring is right.
Can the model cheat by weakening the checks? No. The checks are written and approved before any code exists, and locked by their SHA-256 hash. The fixer only ever changes the sketch. The receipt records the hash of the bench it passed, and the flash gate only opens for firmware that passed a bench a person approved.
What if the model never gets it right? After five fixes it stops and says so, showing what still fails. The gate stays shut for that firmware.
Does my code go anywhere? Only to your own model provider, through Hermes, for /bench. Compiling and simulating happen on your machine. Live links carry the firmware after the #, which browsers never send to a server.
How long does it take? Compiling and running every test takes about 5 seconds a round. The rest is the model: the demo went green in 19 seconds over two fixes on gemini-3.5-flash; the Telegram run above, on a slower model with four fixes, took about six minutes from approval to the result.
Why only the Uno? It's the most common Arduino, and its chip has a mature open emulator. ESP32 and I2C parts are the next step.
The Checks
A bench is JSON. This is the greenhouse fan from examples/greenhouse-fan/bench.json, shortened:
{
"name": "greenhouse-fan",
"parts": [{"id": "temp", "type": "lm35", "pin": "A0", "start": 25},
{"id": "fan", "type": "relay", "pin": "D7"},
{"id": "led", "type": "led", "pin": "D13"}],
"steps": [{"id": "boots_off", "expect": {"part": "fan", "stays": "off", "for_ms": 1500}},
{"id": "hot_turns_on", "set": {"temp": 32}, "expect": {"part": "fan", "becomes": "on", "within_ms": 1000}}],
"always": [{"id": "heartbeat", "expect": {"part": "led", "blinks_hz": 1}}],
"unplugged": {"temp": {"fan": "on"}}
}
- Steps run back to back on one timeline. A step's
setchanges its inputs when it starts. Itsexpectis one of:becomes: reach a state by a deadline and hold itstays: hold a state for the whole stepblinks_hzserial: a line containing some text
- States are
on/off, an LED's brightness in %, a servo angle, or a buzzer pitch. alwayschecks hold over the whole run.unpluggedgives each sensor's fail-safe state.
The full format, with every part, is what the bench_guide tool returns (benchforge/prompts.py).
Golden Benches
| Example | Parts | What the first draft gets wrong |
|---|---|---|
| greenhouse-fan | LM35, relay, LED | the heartbeat breaks when millis() wraps; the relay chatters when the sensor is unplugged |
| button-toggle | push button, LED | contact bounce toggles the lamp several times per press |
| parking-sensor | HC-SR04, buzzer | a dead sensor goes silent instead of warning |
| servo-knob | potentiometer, servo | a broken knob wire makes the servo thrash |
| incubator-heater | NTC thermistor, active-low relay | single readings let noise switch the heater inside its band; a broken thermistor wire reads as freezing and leaves the heater on |
On every push, CI compiles all ten sketches with the real arduino-cli on Linux, macOS and Windows. Each draft must fail exactly the checks recorded in its expect.json, and each fix must pass them all (tools/golden.py).
What Works Today
| Area | Status |
|---|---|
| Compile with the real arduino-cli and AVR core, sealed | Works; CI on Linux, macOS and Windows (Apple Silicon needs Rosetta, Arduino's avr-gcc is Intel-only) |
| ATmega328P simulation with LEDs, relays, buzzer, servo, button, potentiometer, LM35, NTC, HC-SR04 | Works; 5 golden benches plus misbehaving-firmware tests |
| Crash tests: noise, rollover, bounce, unplugged, relay chatter | Works; every one is caught by a golden draft |
Receipts and verify | Works; CI re-runs a receipt and requires an exact match |
| Flash gate | Works; unit and end-to-end tests, and in a real Hermes gateway (below) the agent's own arduino-cli upload was blocked |
/bench, bench_test, bench_guide, hermes bench | Work against a stand-in Hermes in tests and inside a real Hermes (Telegram and the API server); hermes plugins validate (security scan: safe) and doctor pass in CI |
| Board animation (GIF) and live board (browser) | Works; the GIF writer is checked pixel-exact against Pillow, the link decoder is tested against Python's zlib in CI, and the page was checked in headless Chromium at phone size while building it |
| The whole loop with a real model | Works: on gemini-3.5-flash, three plain-English requests (greenhouse fan, button lamp, parking sensor) all reached green, and /bench demo went from 20/23 to 22/22 in two fixes and 19 seconds. On gemini-3.5-flash-lite, /bench demo went green in 4 runs out of 4, two fixes each, in 28 to 43 seconds (run; tools/llm_smoke.py, run on demand in CI) |
| Live run on Telegram with a real model | Works: /bench demo in a real Hermes gateway on Telegram, on gemini-3-flash-preview, went from 20/23 to 22/22 in four fixes and delivered the animation, the bundle and the live link; the agent's untested upload was blocked by the flash gate (Seen working, demo-bot.yml). Not every run reaches green: one stopped at 21/23 and said so |
| The agent on its own, in a real Hermes gateway | Works: asked for a button-toggle lamp and told to test it with BenchForge, the agent (gemini-3.5-flash-lite) found bench_guide and bench_test through Hermes's tool search, wrote its own bench, tested the sketch until it passed and gave the receipt id. Asked to flash it, it ran arduino-cli upload itself and the flash gate stopped it: nobody had approved the checks. It then told the person to send /bench approve (tools/agent_e2e.py, run) |
| Windows | The bench works in CI (compile, simulate, golden benches, receipt verify); not yet run inside Hermes on Windows |
| Other boards (ESP32, Mega, Nano Every), I2C/SPI parts, displays | Not yet: the Uno and the parts above only |
These are simulated parts, not physics. An LM35 here is a perfect 10 mV/°C, a relay switches instantly, and a cut wire is one of two modelled failures. What BenchForge proves is that the firmware's logic handles the cases on the bench. Real boards add things no simulator has.
What It Touches
- Network: only
hermes bench setupdownloads, fromdownloads.arduino.ccandgithub.com, every file SHA-256 pinned or index-verified. Nothing at run time. - Files: writes only to
<HERMES_HOME>/plugin-data/benchforge/: the toolchain, receipts, firmware, drafts (deleted after 7 days), approvals and download bundles. - Programs:
arduino-cli(compile only, never upload) andnode(the simulator, under Node's permission model: no file writes, no child processes, no reads outside its own folder). - Model: through Hermes's
ctx.llmwith your own provider, for/benchonly. It sends your description, the bench, the sketch and failure details (Serial lines clipped, local paths removed). - Stored about people: an approval records the chat platform and a one-way hash of the user id. No names.
- No credentials, telemetry or background processes.
- Live board: a static page on GitHub Pages. Firmware reaches it only in the link's
#fragment, or from a zip you open, and both stay in your browser.
The threat model and five audits are in docs/SECURITY.md.
Built During The Hermes Agent Plugin Hackathon
- Built by Oh-Jay (@Oh_Jay0), a mechatronics student. The code was written with AI (Claude, by Anthropic), directed and tested by Oh-Jay.
- Simulator core: avr8js by Uri Shaked (MIT), vendored as readable JavaScript in
engine/vendor/avr8jsfrom commitbee6f0a. The parts, the bench runner and everything else here is new. - The animation's bitmap font is generated from DejaVu Sans Mono (Bitstream Vera licence) by
tools/make_font.py.
What It Uses
| Thing | Version | Where |
|---|---|---|
| Hermes Agent | >=0.23.0 | the plugin API (ask_choice, post_message, ctx.llm, pre_tool_call) |
| arduino-cli | 1.4.1, SHA-256 pinned per platform | downloaded by bench setup from downloads.arduino.cc (GitHub as backup) |
| Arduino AVR core | arduino:avr@1.8.6 | installed by arduino-cli |
| Servo library | Servo@1.2.2 | installed by arduino-cli |
| avr8js | commit bee6f0a, vendored | the ATmega328P simulator |
| Node.js | 18 or newer (CI uses 22) | runs the simulator under its permission model |
| Python | 3.11 or newer, standard library only | everything else |
| Models used in testing | gemini-3.5-flash, gemini-3-flash-preview, gemini-3.5-flash-lite | through Hermes's own provider (ctx.llm), on Gemini's free tier |
| GitHub Actions and Pages | CI on Linux, macOS and Windows; the Telegram demo bot; the live board |
Build Log
- 8 November 2026: picked the idea and the scope: AI-written Arduino firmware, proven on a simulated chip before it touches a real board.
- 9 November 2026: first commit (05:23 UTC) with the simulator, the checks, the crash tests, receipts and the flash gate. Then the Hermes wiring (
/bench, the agent tools, the gate hook,hermes bench), five security audits, CI on three systems plus a job that installs into a real Hermes, the board animation, the live board, real-model runs on Gemini, the Telegram demo bot and the agent end-to-end test.
License
MIT
README from the reviewed commit 62e6330; it updates when the author re-pins.

ohjay-official
