From 03d3fcab43091fe228f965af5bd70a7b8250006d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Fuente=20P=C3=A9rez?= Date: Fri, 20 Jun 2025 07:58:31 +0200 Subject: [PATCH] Fix data packet ParticipantIdentity override logic in participant.go (#3735) * Fix data packet ParticipantIdentity override logic in participant.go https://github.com/livekit/agents/issues/2554 * Update pkg/rtc/participant.go --------- Co-authored-by: David Zhao --- pkg/rtc/participant.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 1b7e55d5f..503b32291 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -2264,10 +2264,15 @@ func (p *ParticipantImpl) handleReceivedDataMessage(kind livekit.DataPacket_Kind p.pubLogger.Warnw("received unsupported data packet", nil, "payload", payload) } - if p.Hidden() { - dp.ParticipantIdentity = "" - } else if overrideSenderIdentity { - dp.ParticipantIdentity = string(p.params.Identity) + // SFU typically asserts the sender's identity. However, agents are able to + // publish data on behalf of the participant in case of transcriptions/text streams + // in those cases we'd leave the existing identity on the data packet alone. + if overrideSenderIdentity { + if p.Hidden() { + dp.ParticipantIdentity = "" + } else { + dp.ParticipantIdentity = string(p.params.Identity) + } } if shouldForwardData {