agents icon indicating copy to clipboard operation
agents copied to clipboard

KeyError in Room._on_room_event for local_track_published (track SID missing from local_participant.track_publications)

Open MonkeyLeeT opened this issue 1 month ago • 2 comments

Bug Description

KeyError logged and bubbles through _listen_task’s error logging

error running user callback for local_track_published: room_handle: 6 local_track_published { track_sid: "TR_AMLxYxTEBo2L7c" } Traceback (most recent call last): File "/home/appuser/.venv/lib/python3.12/site-packages/livekit/rtc/room.py", line 589, in _listen_task self._on_room_event(event.room_event) File "/home/appuser/.venv/lib/python3.12/site-packages/livekit/rtc/room.py", line 636, in _on_room_event lpublication = self.local_participant.track_publications[sid] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^ KeyError: 'TR_AMLxYxTEBo2L7c'

Expected Behavior

Event should be ignored or publication map populated; shouldn’t raise

Reproduction Steps

- Start LiveKit Agents voice session; 
- User speaks immediately after join; 
- SDK emits local_track_published before the publication map is populated
- KeyError logged from Room._on_room_event

Operating System

Linux

Models Used

No response

Package Versions

livekit-agent=1.3.6

Session/Room/Call IDs

No response

Proposed Solution


Additional Context

No response

Screenshots and Recordings

No response

MonkeyLeeT avatar Dec 08 '25 19:12 MonkeyLeeT

Hi, I tried reproducing this and had no luck. Do you get this error consistently, and do you set up a listener for local_track_published or does it happen on its own? Also, what version are you using for livekit?

tinalenguyen avatar Dec 11 '25 20:12 tinalenguyen

Hi, I tried reproducing this and had no luck. Do you get this error consistently, and do you set up a listener for local_track_published or does it happen on its own? Also, what version are you using for livekit?

It happens on its own, from time to time.

I'm using 1.3.6. Not sure if it's a new issue since I only have error logs restored in recent few weeks.

MonkeyLeeT avatar Dec 11 '25 21:12 MonkeyLeeT

We just encountered this after what appears to be an automatic reconnect of the socket. See attached logs leading up to the error. This was running 1.3.8 on LK Cloud.

keyerror.log

decafdennis avatar Jan 07 '26 17:01 decafdennis