# Example of `generate_reply` usage: call forwarding
@function_tool()
async def forward_call(self, context: RunContext_T):
	"""
	Called whenever the patient wants to be forwarded to a human agent
	"""
	await self.session.generate_reply(
		instructions="Explain politely that you are now going to transfer the patient "
		"to the reception and that the call will be picked up shortly. "
	)
	await asyncio.sleep(3)
	
	try:
		await sip_forward_call()
		return "Forward success!"
	catch:
		return "Tell the patient something went wrong"
	
# ---------------------------

# Attempt at pushing last instructions at the bottom of conversation context
async def generate_reply(
    session: AgentSession[RunContext_T], instructions: str
) -> None:
    system_instruction = llm.ChatMessage(
        role="system",
        content=[instructions],
    )
    session._chat_ctx.insert(system_instruction)

    speech = session.generate_reply(
        tool_choice="none",
    )
    await speech.wait_for_playout()
