Skip to content

Commit 9006870

Browse files
authored
Agent randomly doesn't get audio from the room (#705)
1 parent 2f0b4d8 commit 9006870

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/ripe-moose-exist.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@livekit/agents': patch
3+
---
4+
5+
bugfix: agent not recieving audio from room sometimes

agents/src/voice/room_io/_input.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
22
//
33
// SPDX-License-Identifier: Apache-2.0
4+
import type { AudioFrame } from '@livekit/rtc-node';
45
import {
5-
AudioFrame,
66
AudioStream,
77
type NoiseCancellationOptions,
88
RemoteParticipant,
@@ -66,8 +66,10 @@ export class ParticipantAudioInputStream extends AudioInput {
6666
? participant
6767
: this.room.remoteParticipants.get(participantIdentity);
6868

69+
// We need to check if the participant has a microphone track and subscribe to it
70+
// in case we miss the tracksubscribed event
6971
if (participantValue) {
70-
for (const publication of Object.values(participantValue.trackPublications)) {
72+
for (const publication of participantValue.trackPublications.values()) {
7173
if (publication.track && publication.source === TrackSource.SOURCE_MICROPHONE) {
7274
this.onTrackSubscribed(publication.track, publication, participantValue);
7375
break;

0 commit comments

Comments
 (0)