[Bug] Autopilot plays the first message after the caller barged in before answer() completed
Author: psandersCreated Sep 10, 2026Updated Sep 10, 2026
Labelsbug
Summary
If the VAD emits SPEECH_START while doGreetUser is still awaiting voice.answer() or playDtmf(), the machine moves to listeningToUser, but the greeting actor keeps running and then plays firstMessage on top of the caller.
Steps to Reproduce
Autopilot.start()wires the VAD stream beforeactor.start(), so speech can reach the VAD before the call is answered (early media, or a fast talker on an outbound call).SPEECH_STARTarrives whiledoGreetUseris betweenanswer()andsay(firstMessage).- Machine exits
greetingand runsinterruptPlayback(nothing to stop yet). - xstate cannot cancel the promise;
doGreetUserproceeds tovoice.say(firstMessage)while the machine believes the caller has the floor. The greeting is only cut later whendoProcessUserRequestcallsstopSpeech().
Expected Behavior
Once the caller has barged in, the first message is not played (or is stopped immediately).
Actual Behavior
The greeting starts after the barge-in and talks over the caller until the next turn is processed. Pre-existing; not introduced by #890. Plausible but not confirmed on a live call. Possible fixes: split answering (no SPEECH_START accepted) from greeting, or have the actor check whether the machine is still in greeting before calling say.
Found by code review of #890.
Priority
P2
Source: fonoster/fonoster