Inspiration
Small streamers moderate alone. Built-in filters such as Twitch AutoMod sort chat into a few fixed categories, so they cannot enforce the rules streamers actually say on stream, like "no spoilers past chapter 3" or "no backseat gaming". Cloud moderation bots can, but they send every message to a server and charge per month. A 2023 study of 9,664 Twitch channels found that 98% of hate-raid messages were identity-based, and raids arrive faster than one person can read.
What it does
- You write channel rules in plain English.
- Every chat message gets a verdict (allow, review or remove) with the rule it broke and a short reason.
- Each message shows which lane checked it: on device, cloud, or local checks with no AI.
- Warden is read-only. It suggests a /timeout or /warn command that you copy; it never acts in your channel.
- It reads public Twitch chat anonymously, or runs a scripted demo raid with fictional names.
How hybrid inference is used
Warden has four AI jobs, and each one has its own Firebase AI Logic mode:
| Job | Mode | Why |
|---|---|---|
| Check every message | ONLY_ON_DEVICE, JSON output | High volume: free, instant, chat stays on the machine |
| Second opinion and overflow | ONLY_IN_CLOUD, JSON schema | Only for a stated reason, inside an hourly budget of 120 calls |
| Tune a rule | ONLY_IN_CLOUD, once per rule | Cloud writes a short guide with examples; Nano applies it on every message after that |
| Session recap | PREFER_IN_CLOUD | Not urgent, reads better from the larger model, sends totals only |
A small router decides per message. If the on-device queue would miss a 2.5 second budget (a raid, or a game using the GPU), the message goes to the cloud. The budget halves when the deterministic raid detector fires. If Nano is about to remove a message or is unsure, the cloud gives a second opinion with recent chat as context. Every label comes from the SDK's response.inferenceSource; if the SDK reports a different lane than the router chose, the result is rejected rather than mislabelled.
How we built it
- TypeScript, React and Vite. Firebase AI Logic JS SDK 12.19 with the Gemini Developer API, and App Check (reCAPTCHA v3 in production, debug token in development).
- Chat text is untrusted: it is fenced in prompts, fence characters are stripped, and model output is validated against a schema before use.
- Every model call has a timeout. A failed call sends the message to human review instead of allowing it.
- 104 automated tests, about 96% line coverage. CI runs type check, lint, tests and build.
- The landing page has a live router demo that calls the same routing function as the app.
Challenges we ran into
- Our first real Gemini run let 15 of 24 raid insults through. The default harassment rule only covered identity-based hate, and the model applied it literally. We widened the rule, added a test, and re-ran twice: 24 of 24 raid messages removed both times, and no ordinary messages flagged.
- Gemini Nano needs a GPU with more than 4 GB of VRAM. Our development machine has exactly 4 GB, so the on-device lane could not run there. The app detects this and says so on screen; every check in the video ran in the cloud.
Accomplishments that we're proud of
- Real results on Gemini (two runs on 30 Nov, the second one recorded for the video): 24/24 raid messages removed in both, 11/11 ordinary messages allowed, the spoiler, the spam link and both backseat messages flagged under the right rules, median cloud check about 1.5 seconds.
- Rule tuning turns one plain-English sentence into a guide a small model can follow, with three messages that break the rule and three that are close but fine.
What we learned
The cloud model is most useful as a teacher and a second reviewer, not as the default path. Writing the rule guide once in the cloud and applying it on device is cheaper and keeps chat private.
What's next for Warden
- Run and measure the on-device lane on supported hardware.
- Per-rule actions (review only, or remove) set by the streamer.
- More chat sources than Twitch.
Warden has no users yet, so there are no testimonials or usage numbers here.
Built With
- chrome-built-in-ai
- firebase
- firebase-ai-logic
- firebase-app-check
- gemini-api
- gemini-nano
- gsap
- react
- twitch
- typescript
- vite
- vitest