fix: voice-agent crash — add room I/O options and filter AgentConfigUpdate
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
00be878a95
commit
2112445191
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue