I want to add a delay in the agent's speech in the...
# agents
c
I want to add a delay in the agent's speech in the start of the call. using asyncio.sleep() works in local dev but not in cloud. Is there any reason why it may be failing, or is there a better way to handle this?
l
My guess is you're seeing different behaviour because when deployed, the agent will run through the server lifecycle: https://docs.livekit.io/agents/server/lifecycle/. Maybe wait_for_participant to join first?
c
can we add that to the on_enter function?
l
I was thinking more something like this, in the entrypoint of the agent:
Copy code
# Join the room and connect to the user
    await ctx.connect()

    # Wait for the first participant to join
    await ctx.wait_for_participant()

    # Wait 2 seconds before the agent starts speaking
    await asyncio.sleep(2)

    # Generate the initial greeting
    await session.generate_reply(
        instructions="Greet the user with a warm welcome",
    )