Inspiration

Most Twitch interactions ask viewers to react to a finished game. Chaos Patch lets them rewrite the game while the stream is still running. The audience proposes changes in chat, votes on the next update, and immediately sees a new build—or watches the safety system roll it back.

What it does

Chaos Patch is a live Twitch game and broadcast control room built around a repeatable loop:

  1. The streamer plays Emote Dodge.
  2. Viewers send !patch <idea> in Twitch chat.
  3. The server turns proposals into three candidates.
  4. Viewers vote with 1, 2, or 3.
  5. OpenAI compiles the winning idea into a schema-constrained patch.
  6. The browser game applies it as a new build.
  7. A six-second health check automatically rolls back a destabilizing patch.

The dashboard shows the live phase, timer, proposals, votes, Twitch connection, active build, patch history, recap, and emergency rollback. The same experience is designed for the streamer control room, OBS overlay, and mobile Twitch viewing.

How we built it

  • Twitch Authorization Code flow authenticates the broadcaster without storing OAuth tokens on disk.
  • Twitch EventSub WebSockets receive real channel.chat.message events.
  • Twitch Helix sends chat announcements.
  • The OpenAI Responses API converts the winning idea into a structured, schema-validated game patch.
  • Fastify and WebSockets coordinate round state and push live snapshots.
  • React, Vite, and Canvas render the control room and playable pixel-art arena.
  • OBS Browser Source puts the same live game and patch UI on stream.
  • Vitest and strict TypeScript provide 119 passing automated tests plus a production build gate.

Safety is product behavior: parameters are schema-bounded, server-owned fields are normalized, zero-vote rounds skip model calls, overlapping compiles are deduplicated, and failed health checks restore the previous build automatically.

How we used Codex

The entire project was developed in one continuous Codex thread. Codex turned the plan into a test-first tracer-bullet implementation, researched Twitch and OpenAI integration details, wrote focused tests before behavior changes, ran mechanical gates, operated the real Twitch/OBS rehearsal, diagnosed integration failures, and maintained evidence through final submission.

Codex is the development agent. The shipped product uses the OpenAI Responses API—not a hidden Codex session—to compile viewer ideas into bounded runtime patches.

Challenges we ran into

The hardest boundary was distinguishing application defects from Twitch channel state. Chat, OAuth, EventSub, token refresh, and Helix chat all worked in live tests. Twitch Clip creation remained externally unavailable for this channel, so we kept it out of the core claim and focused the demo on the fully verified proposal → vote → compile → apply → rollback loop.

We also caught a no-participant round that could have triggered an unnecessary model call, then added a no-vote guard and duplicate-compile suppression before recording the final demo.

Accomplishments that we're proud of

  • Real Twitch proposals and votes ship a visible game patch live.
  • The winning idea changes gameplay without deploying frontend code.
  • Unsafe patches roll back automatically with a clear on-screen audit trail.
  • The final real-Twitch run compiled v1.6 “Kappa Burst” and demonstrated automatic rollback.
  • The final gate passes 119 tests, strict type checking, and a production build.

What we learned

Interactive streaming systems need both gameplay safety and integration safety. A bounded patch schema protects the game; idempotent compilation, refresh coordination, reconnect behavior, and explicit degraded states protect the live show.

What's next

More bounded patch parameters, reusable presets, a dedicated branded bot account, and post-stream audience analytics—without weakening the safety contract.

Testing instructions

Clone the public repository, follow the README setup, run pnpm check, then pnpm dev. Connect a Twitch broadcaster, start a session, send three !patch proposals, vote with 1, 2, or 3, and verify the build and game parameters change. Mock Chat is available only as a rehearsal fallback; the submitted video demonstrates the real Twitch EventSub path.

Built With

Share this project:

Updates

Submission history