_user {"message": "Starting KAORI voice agent for ...
# ask-ai
c
_user {"message": "Starting KAORI voice agent for participant quick_user", "level": "INFO", "name": "app.core.livekit_voice_service", "timestamp": "2025-09-07T164917.214727+00:00"} 2025-09-07 221917,790 - livekit.agents - ERROR - unhandled exception while running the job task Traceback (most recent call last): File "D:\conda\envs\companion_env\Lib\site-packages\opentelemetry\util\_decorator.py", line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\conda\envs\companion_env\Lib\site-packages\livekit\agents\ipc\job_proc_lazy_main.py", line 240, in _traceable_entrypoint await self._job_entrypoint_fnc(job_ctx) File "D:\Productivity_companion\backend\app\core\livekit_voice_service.py", line 429, in entrypoint session = AgentSession( ^^^^^^^^^^^^^ TypeError: AgentSession.__init__() got an unexpected keyword argument 'room' {"message": "unhandled exception while running the job task", "level": "ERROR", "name": "livekit.agents", "exc_info": "Traceback (most recent call last):\n File \"D:\\conda\\envs\\companion_env\\Lib\\site-packages\\opentelemetry\\util\\_decorator.py\", line 71, in async_wrapper\n return await func(*args, **kwargs) # type: ignore\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"D:\\conda\\envs\\companion_env\\Lib\\site-packages\\livekit\\agents\\ipc\\job_proc_lazy_main.py\", line 240, in _traceable_entrypoint\n await self._job_entrypoint_fnc(job_ctx)\n File \"D:\\Productivity_companion\\backend\\app\\core\\livekit_voice_service.py\", line 429, in entrypoint\n session = AgentSession(\n ^^^^^^^^^^^^^\nTypeError: AgentSession.__init__() got an unexpected keyword argument 'room'", "timestamp": "2025-09-07T164917.790165+00:00"}
t
Thanks for reaching out, raj. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! The error is happening because the
AgentSession
class doesn’t take a
room
parameter when you create it. Instead, you’ll want to pass the
room
to the
start()
method of your
AgentSession
instance. Here’s how you can fix it: just create the
AgentSession
without the
room
parameter, and then pass the
room
when you call
start()
, like this:
Copy code
session = AgentSession(vad=..., stt=..., llm=..., tts=...)
await session.start(agent=my_agent, room=ctx.room)
Give that a try, and it should sort things out! Sources: livekit-plugins/livekit-plugins-hedra/livekit/plugins/hedra/avatar.py | pipeline-llm/ollama_llm.py
c
{"message": "KAORI agent exiting room for user Quick User", "level": "INFO", "name": "app.core.livekit_voice_service", "timestamp": "2025-09-07T165228.135497+00:00"} 2025-09-07 222228,210 - root - ERROR - error running user callback for local_track_published: room_handle: 4 local_track_published { track_sid: "TR_AMqRTh5cbbehyf" } Traceback (most recent call last): File "D:\conda\envs\companion_env\Lib\site-packages\livekit\rtc\room.py", line 560, in _listen_task self._on_room_event(event.room_event) File "D:\conda\envs\companion_env\Lib\site-packages\livekit\rtc\room.py", line 607, in _on_room_event lpublication = self.local_participant.track_publications[sid] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^ KeyError: 'TR_AMqRTh5cbbehyf' {"message": "error running user callback for local_track_published: room_handle: 4\nlocal_track_published {\n track_sid: \"TR_AMqRTh5cbbehyf\"\n}\n", "level": "ERROR", "name": "root", "exc_info": "Traceback (most recent call last):\n File \"D:\\conda\\envs\\companion_env\\Lib\\site-packages\\livekit\\rtc\\room.py\", line 560, in _listen_task\n self._on_room_event(event.room_event)\n File \"D:\\conda\\envs\\companion_env\\Lib\\site-packages\\livekit\\rtc\\room.py\", line 607, in _on_room_event\n lpublication = self.local_participant.track_publications[sid]\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^\nKeyError: 'TR_AMqRTh5cbbehyf'", "timestamp": "2025-09-07T165228.210912+00:00"}
t
Hey there! This error pops up because the app is trying to access a local track publication with the track SID
TR_AMqRTh5cbbehyf
, but it can’t find that SID in the local participant's
track_publications
dictionary. Usually, this happens because of a timing hiccup—where the
local_track_published
event fires before the publication is fully stored. Here’s how you can fix it: 1. Use the Event Arguments: When you’re handling the
local_track_published
event, grab the
LocalTrackPublication
object that’s passed as an argument instead of reaching into
track_publications
directly. 2. Verify Track Publication: Double-check that you’re publishing the track with the right SDK method (like
publish_track
in Python). 3. Check for Premature Access: Make sure your code isn’t trying to access or remove the publication too early. 4. Defensive Programming: To be safe, use
track_publications.get(sid)
or wrap your code in a
try-except
block to handle missing keys without a fuss. Give these a shot, and you should be all set. If you hit any snags, just let me know—I’m here to help! Sources: examples/basic_room.py | packages/livekit-rtc/src/proto/room_pb.ts | livekit-ffi/protocol/room.proto