The Stoat Bridge (Stoat ↔ Hermes)
The bot
hermes#9787that lives in the LTTStore.com Stoat chat. This page is the durable "how it works" — the operational playbook (triage, restart rules, gotchas) lives in the agent'sstoat-bridgeskill. Verified 2026-11-29.
What it is (in one breath)
A Python service on the compute box keeps a live websocket connection to Stoat
as the bot account. When a human posts in a bridged channel, it turns the
message into a hermes chat one-shot run (a real, full Hermes session with all
tools), streams a "typing…" indicator while the model works, chunks the answer
into Stoat's 2000-char limit, and posts it back as the bot. Each Stoat channel
gets its own persistent Hermes conversation (stoat-<channel>#<gen>), so
context/memory is per-channel, and /new starts a fresh generation of that
conversation.
The stack end to end
You (phone/web)
│ https
▼
UDM Pro :443 (WAN 192.168.68.61, port-forward)
▼
NPM/openresty (nas chart, container ix-nginx-proxy-manager-npm-1)
│ TLS off, host stoat.lootgoblin.duckdns.org
▼ → caddy:80 (on the stoat_default docker network)
Caddy (stoat chart container stoat-caddy-1)
▼
Stoat core + web + media containers (chart, 12 containers)
│
│ WS /ws?version=1&format=json ← THE BRIDGE ATTACHES HERE
▼
[compute box 192.168.1.171]
stoat-bridge.service (systemd user unit)
venv python → bridge.py
│ spawns, one at a time:
▼
hermes chat -q "<message>" --continue stoat-<chan>-<N> --create-if-missing
│
▼
Ollama (qwen3.8-27b-128k on the R9700) — the actual brain
Two separate things people conflate: the Stoat app stack (12 containers on
the NAS, the chat itself) and the bridge (the ~60KB Python file bridge.py
on the compute box). If Stoat web is down it's the app stack / NPM chain; if
Stoat loads but the bot is silent it's bridge.py or the model.
bridge.py — what it does, feature by feature
Location: ~/.hermes/tools/stoat-bridge/bridge.py, run under
~/.hermes/tools/stoat-bridge/venv (aiohttp + livekit 1.2.1). Config from
~/.hermes/.env: STOAT_API, STOAT_WS, STOAT_BOT_TOKEN.
| Subsystem | In bridge.py as | What you see in Stoat |
|---|---|---|
| WS connect + auth | Bridge.__init__, ready handler |
(invisible) — token goes in an Authenticate message; putting it in the URL `?token=*** this build rejects with InvalidSession |
| Message intake | on_message → queue |
every channel you mention/post in gets picked up |
| Typing indicator | typing_loop() (10s re-assert) |
"…is typing" while a run is in flight; requires Subscribe {server_id} or bonfire silently drops the events |
| The single worker | worker() (max 1 in flight) |
messages posted mid-run just queue — the bot looks dead but isn't |
| Hermes run | ask_hermes() |
answer = hermes chat -q … --format stream-json, parsed for the final {"type":"result"} line |
| Approval gating | _collect_gates, _approval_decision_hook |
when Hermes flags a dangerous command → bot posts a prompt with ✅ approve once / 🔁 approve for session / ❌ deny pinned as reactions; 10 min silence = deny |
| Attachment in | _grab_attachments |
images → saved to media/, Hermes vision-loads the local path; other files become hint lines; 10MB cap |
| Attachment out | send_reply + _upload_asset |
answer contains MEDIA:/path lines → file uploaded as an asset and attached to the reply |
| Progress ticker | note_event + _TOOL_CTX |
every ~45s the bot edits its "thinking" note: step count + current tool |
| Message limiting | chunking at 1990 chars on line boundaries | (invisible) — Stoat hard-rejects >2000 chars |
| Bridge commands | intercepted in on_message before queueing |
/new (fresh conversation), /stop (kill the in-flight run), /status (uptime/queue/session gen), /help |
| Voice chime | play_chime (livekit) |
a short chime when the bot "joins a call" — see the LiveKit note below |
Timers that matter: RUN_IDLE_S = 1800 (30 min of no output from the model =
run killed + note posted; this is the "30-minute cap" — long silent prefills
on big contexts used to trip the old 10-min cap), RUN_HARD_CAP_S = 10800,
APPROVAL_WAIT_S = 600.
Where the pieces live (file map)
| Path | Machine | What |
|---|---|---|
~/.config/systemd/user/stoat-bridge.service |
box | Restart=always, reads the hermes .env |
~/.hermes/tools/stoat-bridge/bridge.py |
box | the bridge (61KB) |
~/.hermes/tools/stoat-bridge/media/ |
box | inbound attachments (named by Stoat asset id) |
~/.hermes/.env |
box | STOAT_API/STOAT_WS/STOAT_BOT_TOKEN |
| NPM host 9.conf (nas, in container) | NAS | TLS + stoat.lootgoblin.duckdns.org → caddy:80 |
| stoat chart (12 containers) | NAS | the chat app itself |
Bridged scope (LTTStore.com server)
The bot answers in 4 channels (MineCraft, Danger-Zone, Lootgoblin-has-all-of- the-loot, Request for Features). There is no per-user allowlist yet — anyone in a bridged channel can run the bot. If you want to restrict it, say the word and I'll add one.
Voice / LiveKit (current status)
Stoat has a LiveKit node for voice. The bridge has working "join + chime"
code (publishes chime.wav into a room), but publishing times out over the
public hairpin path — the UDP/TURN leg from the box to the node is the
suspect (UDM firewall 7841–7850 UDP / livekit TURN config). No human voice
has been validated. Treat voice as experimental and likely-broken; text
chat is the supported path.
When the bot "isn't responding" — the ordered checklist
- Is the API up at all?
curl -sk -m 20 https://stoat.lootgoblin.duckdns.org/api/From the box. 502/504/HTML = the NPM→caddy chain is broken, not the bridge. - Is the service alive?
systemctl --user status stoat-bridge+ recent journal. A crash-loop shows tracebacks; a silent journal can mean a stuck child socket (deadhermes chatchild holding the single worker). - Is it RECEIVING? journal lines like
<display> <uid> in <chan_id>log every accepted message. Zero of them while you know you posted = wrong channel/server, or intake broken. - Are you posting where the bot lives? newest human message per channel via REST — the bot only reads those 4 channels.
- Stale code? compare
bridge.pymtime vs the service start time; the running process only picks up edits on restart — and a restart kills the in-flight reply, so only restart when nothing is being answered. - Model contention — the 27B model is single-slot. If you're also chattering with me on Discord/CLI, Stoat runs starve behind it. This is the top cause of "10+ minute no output."
The serving chain (Stoat only) — full detail
See The Proxies for every NPM host, the NPM internals
(openresty, where confs live inside the container, the npm-not-root
reload trap, the .bak discipline), and the famdocs nginx that is not
part of this chain.
Created 2026-11-29 from the live service + skill inventory. Deep operational
gotchas (WS auth quirks, reaction-API routes, rebuild recipes) stay in the
stoat-bridge skill — this page is the durable map, the skill is the repair
manual.