From 2112445191fd8f9a4d7e4edf143824f084cb4ca3 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 28 Feb 2026 21:08:07 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20voice-agent=20crash=20=E2=80=94=20add=20?= =?UTF-8?q?room=20I/O=20options=20and=20filter=20AgentConfigUpdate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add room_input_options/room_output_options to session.start() so agent binds audio I/O and stays in the room - Add wait_for_participant() before starting session - Filter AgentConfigUpdate items in agent_llm.py (no 'role' attribute) Co-Authored-By: Claude Opus 4.6 --- packages/services/voice-agent/src/agent.py | 5 +++++ packages/services/voice-agent/src/plugins/agent_llm.py | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/services/voice-agent/src/agent.py b/packages/services/voice-agent/src/agent.py index cfa897d..d0010cc 100644 --- a/packages/services/voice-agent/src/agent.py +++ b/packages/services/voice-agent/src/agent.py @@ -176,9 +176,14 @@ async def entrypoint(ctx: JobContext) -> None: tts=tts, ) + # Wait for the user participant to connect before starting + await ctx.wait_for_participant() + await session.start( agent=IT0VoiceAgent(), room=ctx.room, + room_input_options=room_io.RoomInputOptions(), + room_output_options=room_io.RoomOutputOptions(), ) logger.info("Voice session started for room %s", ctx.room.name) diff --git a/packages/services/voice-agent/src/plugins/agent_llm.py b/packages/services/voice-agent/src/plugins/agent_llm.py index 4338d7e..cec7f92 100644 --- a/packages/services/voice-agent/src/plugins/agent_llm.py +++ b/packages/services/voice-agent/src/plugins/agent_llm.py @@ -91,10 +91,13 @@ class AgentServiceLLMStream(llm.LLMStream): async def _run(self) -> None: # Extract the latest user message from ChatContext + # items can contain ChatMessage and AgentConfigUpdate; filter by type user_text = "" - for msg in reversed(self._chat_ctx.items): - if msg.role == "user": - user_text = msg.text_content + for item in reversed(self._chat_ctx.items): + if getattr(item, "type", None) != "message": + continue + if item.role == "user": + user_text = item.text_content break if not user_text: