agents icon indicating copy to clipboard operation
agents copied to clipboard

Switch VideoAvatars for AgentSession with multiple agents

Open Viktoriagrg opened this issue 1 month ago • 4 comments

Bug Description

When using VideoAvatars with multiple agents under a single AgentSession, the audio input/output (QueueAudioOutput) is initialized once when the avatar starts. Currently, there’s no way to reset or reassign the audio buffer for a different avatar of the same AgentSession.

This means we cannot smoothly switch avatars without restarting the AvatarSession, which causes a brief moment of the video closing.

Expected Behavior

  • The audio buffer should support resetting or reassigning per avatar.
  • Switching avatars should happen smoothly with no video interruption.

Reproduction Steps

Some have tried to switch avatars by reassigning the destination_identity of the audio output:

self.session.output.audio.destination_identity = avatar._avatar_participant_identity

However, this does not solve the problem. The reason is that the audio buffers for already-started avatars have already been created and tied to the initial avatar session.

self._audio_buffer = QueueAudioOutput(sample_rate=SAMPLE_RATE) await self._audio_buffer.start() self._audio_buffer.on("clear_buffer", self._on_clear_buffer) agent_session.output.audio = self._audio_buffer
  • Once the avatar is started, the _audio_buffer is bound to the session and cannot be reset or reassigned to another avatar dynamically.
  • Simply changing destination_identity does not create a new audio buffer or detach the old one.

Operating System

macOS

Models Used

No response

Package Versions

livekit==1.0.20
livekit-agents==1.3.6

Session/Room/Call IDs

No response

Proposed Solution

add restart() method to AvatarSession, something like:


async def restart(self):
        self._audio_buffer.on("clear_buffer", self._on_clear_buffer)
        self._agent_session.output.audio = self._audio_buffer


also update identity in `switch` method

Additional Context

No response

Screenshots and Recordings

No response

Viktoriagrg avatar Dec 18 '25 15:12 Viktoriagrg