Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions livekit-agents/livekit/agents/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,6 @@ def simulation_context(self) -> SimulationContext | None:
if self._simulation_resolved:
return self._simulation_ctx

self._simulation_resolved = True

metadata = ""
for participant in self._room.remote_participants.values():
if ATTRIBUTE_SIMULATOR not in participant.attributes:
Expand All @@ -467,8 +465,14 @@ def simulation_context(self) -> SimulationContext | None:
# fake_job_context places it there too
metadata = self._info.job.metadata
if not metadata:
# The simulator participant is only visible once the room is
# connected; a miss before then (AgentSession.start consults
# _text_only pre-connect) must not be cached.
self._simulation_resolved = self._room.isconnected()
return None
Comment on lines 467 to 472

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 RoomIO audio setup still uses stale _text_only at pre-connect time

The _text_only property (agent_session.py:1736-1747) is consulted at agent_session.py:694 and agent_session.py:747 during AgentSession.start(), both BEFORE the room is connected. With this PR, simulation_context() correctly returns None without caching at that point, so _text_only returns False. This means the room_options.audio_input = False / room_options.audio_output = False at lines 748-749 won't execute for text simulations, and RoomIO is created with audio enabled at line 772. The dynamic AgentActivity properties (stt, tts, vad at agent_activity.py:3961,3971,3903) DO correctly return None later since they re-evaluate _text_only after connect. This is a pre-existing design limitation (not introduced by this PR) — audio tracks may be unnecessarily published/subscribed before AgentActivity suppresses them. The PR improves the overall situation by ensuring the post-connect path works correctly.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


self._simulation_resolved = True

from google.protobuf import json_format

from livekit.protocol import agent_simulation as sim_pb
Expand Down
Loading