Participant spoken attribution always set to agent
Bug Description
Spoken input from participants is attributed to the agent in chat. Text input is correctly attributed to the participant
Expected Behavior
Spoken input from participants is attributed to the correct participant.
Reproduction Steps
1. Configure an agent that transcribes user speech and publishes transcriptions
2. On the frontend, receive transcriptions
3. Observe participant identity is always the agent's identity
Operating System
Windows 11 (WSL 2)
Models Used
AWS
Package Versions
livekit==1.0.25
livekit-agents[aws]==1.5.0
livekit-plugins-noise-cancellation==0.2.5
livekit-plugins-openai==1.5.0
livekit-plugins-silero==1.5.0
livekit-plugins-turn-detector==1.5.0
livekit-client==2.17.3
@livekit/components-core==0.12.13
@livekit/components-react==2.9.20
@livekit/components-styles==1.2.0
Session/Room/Call IDs
LiveKit Cloud
Proposed Solution
Additional Context
No response
Screenshots and Recordings
No response
@cosmastech, any updates on this? know who to ping to have them take a look?
@Uldiniad could you share a minimal example that can reproduce the issue?
it's only happening when e2ee is enabled
Hi, I'm Himanshu, a new contributor looking for a scoped reproduction task. I read the clarification that this occurs with E2EE enabled and saw #5190 is closed. Would a minimal example comparing spoken vs typed transcription attribution with E2EE on/off help move this forward? Is the issue still reproducible on a current release, and is there a preferred starter example to use?
I have not tried since the last time I posted about it. I can try again on the latest setup but I am nearly certain that it is the case still. I'll try sending what I get
@longcw @himanshumehta10 here's the minimal example. It still reproduces on the latest releases.
# /// script
# dependencies = ["livekit", "livekit-api"]
# ///
import asyncio
import os
from livekit import api, rtc
URL = os.environ["LIVEKIT_URL"]
API_KEY = os.environ["LIVEKIT_API_KEY"]
API_SECRET = os.environ["LIVEKIT_API_SECRET"]
def token(room: str, identity: str, kind: api.AccessToken.ParticipantKind) -> str:
return (
api.AccessToken(API_KEY, API_SECRET)
.with_identity(identity)
.with_kind(kind)
.with_grants(api.VideoGrants(room_join=True, room=room))
.to_jwt()
)
async def run(e2ee: bool) -> None:
room = f"attribution-e2ee-{str(e2ee).lower()}"
encryption = rtc.E2EEOptions(
key_provider_options=rtc.KeyProviderOptions(shared_key=b"repro")
)
options = rtc.RoomOptions(encryption=encryption if e2ee else None)
user, agent = rtc.Room(), rtc.Room()
sender = asyncio.get_running_loop().create_future()
user.register_text_stream_handler(
"lk.transcription", lambda reader, identity: sender.set_result(identity)
)
await user.connect(URL, token(room, "user", "standard"), options)
await agent.connect(URL, token(room, "agent", "agent"), options)
# Publish the user's transcript the way livekit-agents does
writer = await agent.local_participant.stream_text(
topic="lk.transcription", sender_identity="user"
)
await writer.write("hello")
await writer.aclose()
print(f"e2ee={e2ee}: user's transcript arrived from {await sender!r}")
await agent.disconnect()
await user.disconnect()
async def main() -> None:
await run(e2ee=False)
await run(e2ee=True)
asyncio.run(main())
$ LIVEKIT_URL=... LIVEKIT_API_KEY=... LIVEKIT_API_SECRET=... uv run repro.py
e2ee=False: user's transcript arrived from 'user'
e2ee=True: user's transcript arrived from 'agent'
@Uldiniad thanks for the minimal example. I ported it into a test against a local livekit-server --dev (1.13.11) and it reproduces exactly:
| Data-channel encryption | Identity the user's handler sees |
|---|---|
| off | user |
| on, shared key | agent |
| on, per-participant keys | agent |

The cause isn't in agents. room_io passes sender_identity correctly to stream_text. The server exempts an agent's on-behalf text-stream header from identity override only when it can read it in plaintext. With encryption on, the header is inside an EncryptedPacket the server can't inspect, so it stamps the agent's identity on it.
I opened livekit/livekit#5132 with the server code references and three ways to fix it:
- Exempt encrypted packets from agents. Simple, but it would trust an agent's claimed sender for every encrypted type, RPC included.
- Carry the on-behalf identity inside the encrypted payload. The cleanest, but it needs protocol and SDK changes.
- Frontend fallback using
lk.transcribed_track_id. A workaround, and the one you can apply today.
Test used: test_transcription_e2ee_attribution.py. Run it with --runxfail to see the two encrypted cases fail.