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
14 changes: 13 additions & 1 deletion livekit-agents/livekit/agents/voice/agent_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ async def start(
capture_run: Literal[True],
room: NotGivenOr[rtc.Room] = NOT_GIVEN,
room_options: NotGivenOr[room_io.RoomOptions] = NOT_GIVEN,
session_host: NotGivenOr[bool] = NOT_GIVEN,
record: bool | RecordingOptions = True,
# deprecated
room_input_options: NotGivenOr[room_io.RoomInputOptions] = NOT_GIVEN,
Expand All @@ -833,6 +834,7 @@ async def start(
capture_run: Literal[False] = False,
room: NotGivenOr[rtc.Room] = NOT_GIVEN,
room_options: NotGivenOr[room_io.RoomOptions] = NOT_GIVEN,
session_host: NotGivenOr[bool] = NOT_GIVEN,
record: bool | RecordingOptions = True,
# deprecated
room_input_options: NotGivenOr[room_io.RoomInputOptions] = NOT_GIVEN,
Expand All @@ -846,6 +848,7 @@ async def start(
capture_run: bool = False,
room: NotGivenOr[rtc.Room] = NOT_GIVEN,
room_options: NotGivenOr[room_io.RoomOptions] = NOT_GIVEN,
session_host: NotGivenOr[bool] = NOT_GIVEN,
record: NotGivenOr[bool | RecordingOptions] = NOT_GIVEN,
# deprecated
room_input_options: NotGivenOr[room_io.RoomInputOptions] = NOT_GIVEN,
Expand All @@ -859,6 +862,12 @@ async def start(
Args:
capture_run: Whether to return a RunResult and capture the run result during session start.
room: The room to use for input and output
session_host: Whether a `RemoteSession` can drive and observe this session
over the room. Defaults to True, or False when another session in the
same job is already the primary. Set False when the room already has
its agent and this session is only a participant in it, such as a
client talking to that agent. Ignored under the console subcommand,
where hosting is how the console reaches the session at all.
room_input_options: Options for the room input
room_output_options: Options for the room output
record: Whether to record the audio, transcripts, traces, or logs
Expand Down Expand Up @@ -900,6 +909,9 @@ async def start(

job_ctx.init_recording(self._recording_options)

# hosting needs the primary designation as before, and the caller's consent
hosting = is_primary and (session_host if is_given(session_host) else True)
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.

# Under a text simulation the simulated user interacts over text
# streams only: disable audio I/O here, and STT/TTS/VAD via
# AgentActivity (both consult _text_only).
Expand Down Expand Up @@ -984,7 +996,7 @@ async def start(
self._room_io = room_io.RoomIO(room=room, agent_session=self, options=room_options)
await self._room_io.start()

if is_primary:
if hosting:
# only the primary session can have a session host
transport = RoomSessionTransport(room)
self._session_host = SessionHost(transport)
Expand Down
Loading