Why am i getting multiple agents when I use the co...
# ask-ai
m
Why am i getting multiple agents when I use the console? my code beliw async def entrypoint(_ctx_: JobContext) -> None: session = AgentSession() session.userdata = AppointmentData() session.state = {"current_node": "collect_patient_info"} await session.start(agent=CollectPatientInfoAgent(ctx), room=ctx.room, _room_input_options_=RoomInputOptions( _noise_cancellation_=noise_cancellation.BVC(), ), ) await session.generate_reply( instructions="Offer to help schedule an appointment." ) _# ctx.add_shutdown_callback(save_user_info)_
t
Thanks for reaching out, Nikki. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand how seeing multiple agents in the LiveKit console can be a bit confusing. This usually happens because of how the code is set up, especially if it's based on multi-agent examples. In those cases, there might be features like agent handoff, where new agent instances are created during the session—this can occur through function tools or session updates that switch between agents automatically. To help keep things simple and avoid this, you might want to check that your implementation doesn’t include agent handoff mechanisms such as
session.update_agent()
or function tools that spawn new agent instances. If you’re aiming to use just one agent, simplifying your code to remove these patterns can make a big difference. Please feel free to reach out if you'd like me to walk you through modifying your code or if you have any other questions. I’m here to help! Sources: livekit-agents/livekit/agents/voice/agent_session.py | main.py | metrics/metrics_stt.py