creamy-match-85520
08/06/2025, 4:50 AMtall-airline-16756
08/06/2025, 4:50 AMtall-airline-16756
08/06/2025, 4:51 AMAgentSession
. Here’s how you can do it:
1. Use the aclose()
method on the AgentSession
instance. This will handle shutting down the session gracefully.
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
# ... stt, llm, tts, etc.
)
avatar = hedra.AvatarSession(
avatar_id="...", # ID of the Hedra avatar to use
)
# Start the avatar and wait for it to join
await avatar.start(session, room=ctx.room)
try:
# Start your agent session with the user
await session.start(
# ... room, agent, room_input_options, etc....
)
finally:
# Close the session when done
await session.aclose()
By closing the AgentSession
, the associated avatar session will also be properly terminated. Let me know if you need further assistance!
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime...