A coding agent for firmware that proves its fixes, on the fewest tokens.
Website ·
Proof ·
Run it ·
Evaluation guide ·
Releases
For judges: claims → code → proof ·
Bifrost integration ·
Testing ·
Pitch deck ·
Website
BoardLoop is a coding agent for embedded firmware that gets the job done on the fewest tokens.
It writes and fixes ESP32/Arduino code, proves the fix on a compiler and a simulated circuit,
keeps working when an AI provider goes down, never spends past a per-user budget, keeps
confidential code on a local model, and asks before every risky action (writing files, flashing
a board).
Built for the Geek Room Global AI Hackathon, theme "Build a Coding Agent That Gets the Job
Done on the Fewest Tokens", on Bifrost by Maxim AI as the LLM gateway.
The problem
Coding agents burn tokens: every fix round re-sends the whole file, the whole compiler log and the
whole chat history, and the model is asked even when the compiler already says what's wrong. They
stop when one provider has an outage, they have no spending limit per person, they send private
code to the cloud, and many write files or run tools without asking.
How BoardLoop solves each requirement
| Theme requirement |
What BoardLoop does |
Where |
| Fewest tokens |
1. Deterministic fixes first: errors the compiler fully explains (e.g. a missing ;) are fixed by code, 0 tokens. 2. Fix cache, "reason once": a fix that led to a verified build is stored under an error fingerprint and replayed next time with 0 model calls. 3. Compact prompts: only the first compiler error (later ones are usually caused by it) and ±4 lines around it; for behaviour bugs only the decision lines (comparisons). No chat history. |
coder.py |
| Correctness |
Nothing counts as done until mcu_verify passes: real compile + behaviour tests on a simulated circuit (sensors, pins, serial, OLED). Fix budgets (3 compile, 5 behaviour) stop endless loops. |
loop.py |
| Survives provider outages |
Calls go through Bifrost with a model chain (fallbacks), so Bifrost switches provider server-side. If the gateway itself is down, the client walks the chain and finally calls local Ollama directly. |
gateway.py |
| Per-user spending limits |
Before every call the worst-case cost is checked against the user's budget; after it, the real cost from the provider's usage is added to a per-user ledger. A Bifrost virtual key (--virtual-key) enforces the same budget on the gateway. Over budget = the agent stops, it doesn't crash. |
gateway.py Budget |
| Confidential repos on local models |
--confidential (or a CONFIDENTIAL file in the project) restricts the chain to ollama/*. If no local model is configured the agent refuses instead of falling back to the cloud. |
Gateway.chain() |
| Approval before risky operations |
Every file write shows a diff and waits for y. Flashing a board asks first. With no terminal attached it answers no. Shell commands are fixed argv templates with timeouts, never a shell. |
coder.ask, procs.py |
flowchart LR
V[mcu_verify<br/>compile + simulated tests] -->|verified| D[done · report tokens/$]
V -->|fix needed| R{rule fix?}
R -->|yes, 0 tokens| W
R -->|no| C{fix cache hit?}
C -->|yes, 0 tokens| W
C -->|no| P[compact prompt<br/>1 error + few lines]
P --> B[Bifrost gateway<br/>budget · fallbacks · virtual key]
B --> M1[cloud model] & M2[fallback model] & M3[Ollama local<br/>confidential only]
B --> W[diff → approve? → write]
W --> V
D -->|--port| F[approve? → flash board]
Measured, not claimed
Same task, same planted bugs (a missing ; and a reversed comparison in a thermostat), run by
the naive agent (--baseline: whole file + full tool output + growing history, no rules, no
cache) and by BoardLoop. Numbers are printed by the agent itself from the provider's usage
field; reproduce with the commands under Run it.
Live run through Bifrost (local gateway, bifrost/config.json), model chain
anthropic/claude-haiku-4-5 → groq/openai/gpt-oss-120b, 21 Nov 2026. No Anthropic key was
configured, so every call shows Bifrost's automatic fallback to Groq in action:
| Run |
Result |
LLM calls |
0-token fixes (rule/cache) |
Tokens (in+out) |
Cost (USD) |
| Baseline (naive agent) |
verified |
1 |
0/0 |
1,951 (1,630+321) |
$0.000437 |
| BoardLoop, first time |
verified |
1 |
1/0 |
504 (345+159) |
$0.000147 |
| BoardLoop, same bugs again |
verified |
0 |
0/2 |
0 |
$0.000000 |
BoardLoop, user bob with a $0.00001 budget |
budget_exceeded |
0 |
1/0 |
0 |
$0.000000 |
Bifrost's own request log and dashboard for these runs (red = Anthropic refused, green = Groq answered via fallback):
| LLM Logs |
Dashboard |
 |
 |
| Fallback + 504 tokens |
Same bugs again: 0 tokens |
Naive agent: 1,951 tokens |
 |
 |
 |
| Budget stop |
Confidential: Ollama only via Bifrost |
 |
 |
Terminal output of each run, unedited (first run,
same bugs again, naive baseline,
budget stop):
These runs used the repo's offline arduino-cli/wokwi-cli stand-ins (--fake-tools), because
the ESP32 core and a Wokwi token weren't available on the recording machine; every token, cost
and provider number above is real and comes from Groq via Bifrost.
That is 74% fewer tokens and 66% lower cost on the first run, and 100% fewer on every
repeat. The missing ; never reaches the model (fixed from the compiler message), and only the
comparison lines are sent for the behaviour bug. Small local models (llama3.2 3B) get the
compile fix for free too, but are not strong enough to fix the logic bug on their own: use them
for confidential work and as the last fallback, with a stronger model first in the chain.
The CI test test_compact_prompt_uses_far_fewer_tokens_than_baseline
fails if BoardLoop ever uses more than a third of the baseline's tokens, and
test_fixes_both_bugs_and_replays_from_cache fails if a repeated bug costs a single token. Full suite: 197 tests pass (python -m pytest -q).
See it fix a real ESP32 thermostat, step by step
A DHT22 temperature sensor, an SSD1306 OLED and an LED on an ESP32, simulated on Wokwi. The sketch
has two planted bugs: a missing ; and a reversed comparison. Every frame below comes from one
unedited run of the same fix loop (mcu_verify), driven from the Hermes Agent chat (left) with
the circuit on Wokwi (right):

| Step |
What happens |
Frame |
| 1. Compile fails |
arduino-cli reports 4 errors; only the first one matters: expected ',' or ';' before 'Adafruit_SSD1306' |
 |
2. Fix the ; |
One line changed: const float THRESHOLD_C = 30.0; (BoardLoop's agent does this for 0 tokens) |
 |
| 3. Compiles, but a test fails |
Hot room at 35 °C: expected serial 'LED=ON' not seen, the firmware printed LED=OFF |
 |
| 4. Fix the logic |
t < THRESHOLD_C becomes t > THRESHOLD_C (the one model call: 504 tokens via Bifrost) |
 |
| 5. Verified 3/3 |
All behaviour tests pass, with OLED screenshots from each test |
 |
| 6. Flash only with approval |
Writing to a real board stops at an approval prompt |
 |
The same circuit running live in the wokwi.com editor (DHT22 at 35 °C, OLED alert, LED on), and
the OLED screenshots BoardLoop captured during its test run:
| Live on wokwi.com |
OLED screenshots from the tests |
 |
 |
Run it