
Subscribe
Tags
Voice AI
AI Agents
Developer Tutorials
This post closes a nine-part tutorial on building a talking jack-o'-lantern, and if you're new to the series, start with part 1. In part 8 the pumpkin got an operator. In this part I test it without any visitors, and then I watch it while it runs for a whole night.
An agent like this needs more than one kind of test. Unit tests check the logic, and a replay of a recorded night checks the wiring between that logic and the platform. A real call with a fake audience checks everything together. Once the night starts, a second AI grades every reply while a live log shows me what's happening.
Test without a call
Most of the pumpkin's logic is plain code, so it gets plain tests. Node tests cover the stage detection from part 5, and Python tests cover the visit state and pacing from part 7. The stage tests run scripted scenes with timer jitter built in, because real browser timers wander.
The agent's own pieces can be tested without a call too, using swaig-test from our Python SDK. Part 2 used it to print the SWML, and part 3 used it to run a tool with chosen arguments and global_data.
Replay a recorded night
Unit tests check each piece alone, but the wiring between the pieces holds bugs of its own. To find those, I replay a recorded night through the real server code. The live log, which I describe below, records every event from a night: arrivals, what was said, every tool call, and every context change. The replay feeds those events back through the server's actual routes and tool handling.
The replay takes the model's tool calls from the recording, and they stand for what the model would have tried. A small model of the platform sits between the server and the recording. It applies each tool result's context and step changes, and it offers only the tools each step lists. A four-hour night replays in about 25 seconds and ends in a report.
"Wrong mode" is the number to watch. It counts the minutes when the platform's context disagreed with the server's choice, broken down by kind. Any change to the visit state shows up there as fewer minutes or more. "Not offered" lists the tools the model tried to call in a step that doesn't list them. Each of those points to a prompt that names the wrong tool or to a step that's missing one.
A real call with a fake audience
The replay can't test the call itself, meaning the voice, the vision, and the page. I test those with a real call and a fake audience. Chrome can use a video file as its camera and an audio file as its microphone.
The camera file is a Motion-JPEG movie that ffmpeg builds from still pictures. Those pictures are AI-generated to avoid privacy concerns with photos of kids. It shows an empty yard, a group of teenagers, and a small child with a parent. The mic file holds lines spoken with macOS's say command, which ffmpeg places on a timeline and mixes into one WAV. On macOS, Chrome's audio sandbox has to be off, or Chrome never reads the WAV and the fake mic stays silent. I press Start on the page, let it run, and read the result back from the live log.
Grade every reply
A whole night is one long call with a hundred shows, so a summary at the end comes too late to act on anything. Instead I attach our AI sidecar, a second AI on the same call that listens and never speaks. It gets its own prompt, which describes the character the way a reviewer would. For each visitor's line it predicts what the pumpkin should say, and then it grades what the pumpkin actually said.
The sidecar hears only speech. It doesn't know which mode the pumpkin is in, which tools it called, or that the stage camera has reported a group leaving. Left with speech alone, it grades correct behavior as wrong, and a gentle line to a child looks like the character going soft. So my server fills it in with a short note on every mode change, every tool call, and the shoo point from part 7. Its grades go to a page that lists problems first, and a script turns them into a report, grouped by problem, for tuning.
Watch it live
The live log is one compact line per debug event, covering what visitors said, what the pumpkin said, every tool call, and every step change. I can read it from my phone during the show. On Halloween that's how I found that visitors kept holding things up and asking "what is this?" The pumpkin didn't know what people were looking at, so it had no good answer and kept claiming it was blind. That night I shipped a new tool, guess_what_it_is, which gives a confidently wrong verdict without looking.
Deploy without dropping the call
The call runs all night, so a deploy can't end it. The tests run before every deploy. The container mounts the code read-only, and a file watcher restarts only the Python process when a .py file changes. A filter keeps a change to the page or a log file from restarting anything.
After a deploy, /version reports which commit the process started from. A deploy counts as done only when that commit matches, so a crash on start can't hide behind the old process.
Traps to avoid
Don't stop at testing the logic. Replay through the real server code as well, because the wiring between the pieces holds bugs the logic doesn't.
Don't drive Web Audio tests with Playwright on macOS. In a Playwright-driven browser, audio worklets never finish loading. Use a normal Chrome window instead, with Chrome's audio sandbox turned off for the fake mic.
Don't give a grader only what it hears. Tell it the mode and the events it can't hear, or it'll grade correct behavior as wrong.
The code
The ai-jackolantern repository has the complete code for all nine parts. This is the actual running code that ran 366 visits on Halloween night this year.
The series
The agent: a personality and three modes, as contexts and steps.
Tools: what the AI calls on my server, and why its material lives in code.
Vision: letting the agent see, and checking the camera before any decision that matters.
The stage: detecting who is standing in front of the pumpkin, in the browser.
The operator: a person with a phone who can overrule the agent.
Testing it, and running it for a whole night (this post).
Related Resources






