-
-
Boss Forge: chat designs the boss, OpenAI Codex builds it, the streamer has to survive it.
-
Forge console: approvals, live Codex build log, verified queue and honest LIVE CODEX / CACHED REPLAY labels.
-
Live Codex forging a viewer's "!boss a giant toaster" idea: attempt 1/3, Read → Write → Test, next to real chat.
-
The arena: original procedural bullet-hell drawn as a live technical drawing. Four bosses playable in-browser.
-
Chat typed !rematch. Codex built a harder Crumbustion MK II, and it passed the same fairness gate (bot won 3/5).
-
The landing page runs the real game engine live, next to the chat → Codex → gate → arena flow.
-
Live on a real Twitch channel: OBS overlay over the arena with boss card, viewer quote, gate results and real chat.
Inspiration
Twitch already has lots of games that chat can play along with: chat votes, spawns enemies, picks a door. But chat never gets to make the game. We wanted the most creative person in chat to be able to type one sentence and, about a minute later, watch the streamer fight the thing they imagined, with their name on it.
The hard part is not generating a boss. It's generating one that is new every time, actually playable, and fair enough to put in front of a live audience, so that a troll can't make the stream unwinnable.
What it does
- A viewer types
!boss a giant toaster that shoots flaming breadin Twitch chat, or redeems the Forge a Boss Channel Points reward. The bot replies with a short code, and the streamer or a mod approves it with!approve. - Codex builds it, live. Each request opens an OpenAI Codex SDK thread in a locked-down workspace. Codex gets:
- a typed BossAPI;
- the rules in
forge/AGENTS.md; - the viewer's words, passed in as untrusted data and never as instructions.
Codex writes boss.json (attack patterns, phases, movement and taunts) plus optional TypeScript choreography, which compiles inside an isolated QuickJS sandbox. It runs the local checks and fixes its own mistakes, for up to three attempts. The overlay shows each step as it happens: attempt n/3, reading, writing, testing, verifying.
- The fairness gate decides. The server, not Codex, re-runs an unchangeable gate on the actual spec. A reference dodger bot with roughly 100 ms reactions fights the boss five times.
- It must win at least 2 of 5 (beatable) and lose at least 1 (interesting).
- A safe space must always exist.
- Laser warnings must be long enough, and p99 tick time must stay under budget.
A failing boss is rejected ("too unfair to ship") and its Channel Points are refunded automatically.
- The streamer fights it in an original bullet-hell arena with procedural art and WebAudio sound. A transparent 1920×1080 OBS overlay shows:
- the boss card and the viewer's quote;
- the gate results, check by check;
- the queue;
- a live "inside the forge" ticker of what Codex is doing.
- The show keeps going:
- After a win, chat types
!rematch. Codex reads the beaten boss and the fight stats and patches a harder MK II, which must pass the same gate. !vote 1/2/3polls let chat pick the next boss.- A persistent Hall of Fame (
!top,!record,!mybosses) tracks whose bosses beat the streamer.
- After a win, chat types
Setup takes minutes: npm run auth -- broadcaster, npm run auth -- bot, one OBS browser source, and a /setup/ readiness checklist.
Try it:
- Play the built-in bosses in your browser, with no install: https://ayushagarwalhere.github.io/boss_forge/
- Full show demo with simulated viewers and clearly labeled cached replays: https://bossforge.16-178-179-90.sslip.io/
How we built it
Codex is in two layers.
Building the product. Boss Forge was built in OpenAI Codex, milestone by milestone:
- M0: contract and tooling.
- M1: the deterministic 60 Hz engine and arena.
- M2: the fairness gate.
- M3: the Codex forge.
- M4: Twitch and the OBS overlay.
- M5: moderation, sound and isolated scripts.
AGENTS.md files hold the project's rules for every Codex session: no secrets in the browser, viewer text as data, honest labels for demo replays, and never weakening gate checks. Teammate pull requests added the landing page, the editorial UI redesign of every page and the arena graphics, motion polish and the show layer on top of the Codex-built core.
Running the product. Every viewer request is a real Codex SDK run (@openai/codex-sdk).
- The server streams Codex's typed events to the overlay.
- It keeps the thread for follow-up repair attempts.
- It enforces a workspace-write permission profile that denies reads outside the workspace and allows no network.
Codex output is never trusted directly. The server re-validates the schema, recompiles scripts in QuickJS and re-runs the gate before anything reaches the queue.
Stack: TypeScript, Node, Vite, Zod, Vitest, Canvas 2D, WebAudio, QuickJS, Twitch EventSub WebSockets and Helix (chat, Channel Points, clips, markers), OBS browser source, and the OpenAI Codex SDK.
Challenges we ran into
- Safety on a live stream. Viewer text is adversarial, so we kept it as data all the way through:
- moderation runs before intake;
- approval is manual by default;
- Codex can only touch an isolated workspace with read-only protected inputs;
- the gate runs on the server, outside Codex's reach.
- "Fair" had to be measurable. We replaced "looks fine" with a reproducible bot-based gate, deterministic seeds and recorded reports.
- A sandbox that really holds. Codex runs with outside reads denied. On Linux, that first blocked Codex from re-launching itself inside its own sandbox. We granted read-only access to just its own package, then verified that the workspace stays writable while secrets and everything outside it stay unreadable.
- Live platform edge cases. These included refunds when a forge fails, deduplicating EventSub deliveries and reconnect handoffs. Our live test found two more bugs, both now fixed:
- when one account was both broadcaster and bot, the bot ignored the streamer's own commands;
- a moderator's second
!approvein a row could be swallowed by the chat rate limiter.
Accomplishments that we're proud of
- A full loop that works on a real Twitch channel: chat message, live Codex, gate, overlay, fight, rematch. A typical live forge takes about a minute.
- An account-free
npm run demoand a public browser arena, so anyone can try it without keys. Simulated viewers and cached replays are always clearly labeled. - 180 automated tests, covering OAuth ownership, refunds, reconnects, restart recovery, sandbox escapes and gate policy.
What we learned
LLM code generation becomes content you can ship on a live stream when you pair it with an independent, deterministic judge. Codex is the creative engine; the gate is what lets a streamer trust it.
What's next for Boss Forge
- Multi-boss tournaments voted on by chat.
- Shareable boss cards with replay seeds.
- An "ask Codex why" button that explains a rejection in plain language.
- A hosted version, so streamers don't need to run a local server.
Built With
- canvas
- codex-sdk
- eventsub
- node.js
- obs
- openai-codex
- quickjs
- twitch
- typescript
- vite
- webaudio
- zod
Log in or sign up for Devpost to join the conversation.