many-forest-60185
11/04/2025, 12:49 AMtall-airline-16756
11/04/2025, 12:49 AMtall-airline-16756
11/04/2025, 12:50 AMgenerate_reply kicks in right after a call is answered, you can use the on_enter method in your agent class. Here’s a simple way to do it:
class MyAgent(Agent):
def __init__(self, call_answer_delay: float = 2.0):
super().__init__(
instructions="You are a helpful assistant.",
)
self.call_answer_delay = call_answer_delay
async def on_enter(self) -> None:
# Add delay after call is answered but before generating reply
if self.call_answer_delay > 0.0:
await asyncio.sleep(self.call_answer_delay)
# Generate the initial greeting after the delay
self.session.generate_reply(
instructions="Greet the caller politely and ask how you can help them."
)
This way, there’s a nice little pause right after the call connects and just before your agent starts replying. If you have any questions or want to explore this further, I’m here to help!
Sources: examples/voice_agents/multi_agent.py | agent.py