Skip to content
Go back

Local WebGPU Agent Lab with Transformers.js

Posted on:August 15, 2026
Fullscreen Local WebGPU Agent Lab showing Matt and agent-built stations, plants, printed blog images, the conversation output, observability stream, token total, and controls

The local agent can build stations, decorations, and images from my blog while its conversation, tool events, and model state remain visible.

Building on my last Transformers.js experiment in a browser game, Local WebGPU Agent Lab asks: what happens if I give a local, in-browser model a playground in my blog?

Once the models are downloaded (about 1.9–2.3 GB with the current quantization choices), agent inference, speech recognition, and optional speech synthesis run in the browser. You can then start building in the lab with the agent.

Build Together in the Lab

The agent has a sprite kit and a set of reusable nodes to build things with. These stations occupy spaces in the room, and you can click a station to use its controls. The agent can also make decorative changes and other interesting combinations as you play. I lazily reused a character sprite from my GTC San Jose web game for Matt.

You can give the agent a direction like “build a place where we can make music.” It inspects the open lab spaces, chooses one specific output, and selects nodes that might work. I hope to swap in smaller and more capable models in the future and continue to test.

The lab can also use parts of my actual blog, including post metadata, excerpts, images, and references to components used by other posts.

Fullscreen view of Local WebGPU Agent Lab with Transformers.js, showing a Blog Image Printer station in the center, conversation and observability on the right, and Matt's controls along the bottom

This station searches my blog’s image catalog and “prints” the next matching image.

Conversation Output showing final messages exchanged between the user and Matt

Conversation output shows the recent final messages without the model’s raw output.

Observability panel to see local voice playback, model status, synthesis, and worker events

Observability panel with the model, tool, state, and audio events happening locally.

Brain, ear, and mouth model-readiness icons with the loaded agent model named in a tooltip

Brain, ear, and mouth represent the agent, speech-to-text, and text-to-speech models, with tooltips naming each loaded model.

Try the Lab

Click the lab below to open it and try things out!

If WebGPU, its adapter, the worker, or a core model fails, then the lab should open with a compatibility dialog that explains the problem. If it doesn’t - let me know!

Agent Appendix

Agent’s Building Tools

A Web Worker keeps inference responsive. The page still owns the state and turns every accepted tool call into a visible event. Build requests retain a small functional intent instead of collapsing into one generic creative path: music requests are repaired toward playable keyboards, pads, sequencers, waveforms, and different oscillator/scale state, while writing, signal, light, play, and visual requests draw from their own node recipes. Open-ended visual directions can still use gradients, auroras, orbits, ribbons, mosaics, waves, colors, motion, and controls, but that grammar is no longer the default for every machine. A resource-backed music build can bind an exact post or excerpt and deterministically derive its rhythm, tempo, tone root, scale, and oscillator from that source. For open-ended creative builds, the lab records prior titles and design signatures; the host rejects repeats, and the safe fallback excludes them.

Notes for Coding Agents

Local Persistence and Offline Scope

Build breakdown

  • Bundle: about 951 KiB of feature-owned production assets: 574 KiB of sprites and media plus 377 KiB of UI JavaScript, CSS, and worker code; the UI, styles, and worker compress to about 107 KiB over gzip.
  • Code: 31 changed files and about 1.54 MB in the branch; about 30,100 added lines of code and styles, or 24,100 without the 5,979-line repository-only test harness.
  • Astro: the client:only="react" island loads only on this post route, mounting while the article is open so model downloads can run in the background.
  • Models: about 1.9–2.3 GB in total, depending on the agent quantization, including Whisper Tiny and the optional local voice.