We are getting this error while executing an end_c...
# ask-ai
b
We are getting this error while executing an end_call function: RunContext.wait_for_playout() missing 1 required positional argument. What is needed here?
t
Thanks for reaching out, Jose. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're getting that error because
wait_for_playout()
is an instance method and needs to be called on the
RunContext
instance passed into your function, not on the
RunContext
class. In other words, your function must accept
ctx: RunContext
and you should call
await ctx.wait_for_playout()
. Example:
Copy code
@function_tool
async def end_call(self, ctx: RunContext):
    """Called when the user wants to end the call"""
    await ctx.wait_for_playout()   # wait for agent speech to finish
    await hangup_call()            # then hang up / delete the room
If your
end_call
currently has no
ctx
parameter (or you call
RunContext.wait_for_playout()
directly), update the signature and call as shown. Would you like me to review your current
end_call
code if you paste it here? Sources: Agent speech and audio | LiveKit docs | Agents telephony integration | LiveKit docs