I'm building an AI avatar stream that runs unattended. No human broadcaster — the avatar reacts to comments, makes small talk, and carries the show through to the sign-off. Of all the walls you have to get over to make that work, this post covers two problems that both come down to state.

The first is remembering viewers across streams. Whether the avatar can say "oh, you were here last time too" makes a surprisingly large difference to the experience.

The second is where to keep the state during a stream. The renderer (the headless browser that produces the video) crashes. And if the avatar redoes its greeting every time it crashes and reconnects, viewers see a stream that introduces itself once a minute.

Push on either one and you arrive at the same question: which state, at what granularity, held where? I'll go through them in order, and I'll be candid about both the design decisions and the bugs I hit along the way.

Whose memory is it?