#892·fonoster

[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

  1. Autopilot.start() wires the VAD stream before actor.start(), so speech can reach the VAD before the call is answered (early media, or a fast talker on an outbound call).
  2. SPEECH_START arrives while doGreetUser is between answer() and say(firstMessage).
  3. Machine exits greeting and runs interruptPlayback (nothing to stop yet).
  4. xstate cannot cancel the promise; doGreetUser proceeds to voice.say(firstMessage) while the machine believes the caller has the floor. The greeting is only cut later when doProcessUserRequest calls stopSpeech().

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