lively-minister-89835
11/14/2025, 1:11 PM{
"name": "end_call",
"arguments": {}
}/tool_call
This is my end_call tool:
@function_tool()
async def end_call(context: RunContext) -> dict:
"""
Ends the call after user signals goodbye or task completion or
the user is not interested in the conversation.
"""
await context.session.generate_reply(
instructions="Close the call politely based on the conversation history" # noqa: E501
)
# Wait for any current speech to complete
current = context.session.current_speech
if current:
await current.wait_for_playout()
# Delete the LiveKit room to hang up for everyone
job_ctx = get_job_context()
# Stop active egress jobs
request = ListEgressRequest(room_name=job_ctx.job.room.name, active=True)
active = await job_ctx.api.egress.list_egress(request)
for e in active.items:
await job_ctx.api.egress.stop_egress(
StopEgressRequest(egress_id=e.egress_id)
)
await job_ctx.api.room.delete_room(
DeleteRoomRequest(room=job_ctx.room.name)
)
return {"ended": True}better-house-57730
11/14/2025, 2:02 PMtool_choice and set it to required instead of auto. That might helpbetter-house-57730
11/14/2025, 2:07 PMlively-minister-89835
11/14/2025, 2:15 PM