billions-lawyer-8588
08/12/2025, 8:36 PM@function_tool()
async def wait_tool(self):
"""
Called when you detect hold music, or you have been put on hold or the user asks you wait.
"""
# logger.info("[Waiting]")
log.info("[Waiting]")
self.session._chat_ctx.insert(ChatMessage(type="message",role="assistant",content=["[Waiting]"]))
Following are the parameters for the agent session -
for turn detection, I am using EnglishModel().
turn_detection=EnglishModel(),
user_away_timeout=20.0,
vad= silero.vad.load(),
min_endpointing_delay=0.75,
max_endpointing_delay=3.0,
For one of the calls, this is the transcript -
{
'id': 'item_b79e5d6aa9d7',
'type': 'message',
'role': 'user',
'content': ["Okay. Hold on. I'm checking."],
'interrupted': False,
'transcript_confidence': 0.9838867
}, {
'id': 'item_908762549fce',
'type': 'message',
'role': 'assistant',
'content': ['Okay, sure.\n'],
'interrupted': False
}, {
'id': 'item_11e8fb357f4c',
'type': 'message',
'role': 'assistant',
'content': ['[Waiting]'],
'interrupted': False
}, {
'id': 'item_fc6438515241',
'type': 'message',
'role': 'assistant',
'content': ['Okay, great. Could you tell me if the vehicle is released for pickup?\n'],
'interrupted': False
}, {
'id': 'item_f11b78b3224e',
'type': 'message',
'role': 'user',
'content': ["I'm still checking. Hold on a minute."],
'interrupted': False,
'transcript_confidence': 0.9975586
}
Over here, the agent used waiting tool, but again asked a question after some time. It is not waiting till user_away_timeout parameter and not asking the question "are you there" that I have defined for user state changed to away.creamy-byte-34126
08/12/2025, 9:13 PM@session.on("user_state_changed")
def _on_user_state_changed(ev: UserStateChangedEvent):
if ev.new_state == "away":
asyncio.create_task(inactivity_handler(session))
In inactivity function you can ask is user still in there
async def inactivity_handler(session: AgentSession):
"""Handle user inactivity by playing a message and eventually hanging up
This method is called when the user_away event is triggered after
user_away_timeout seconds of silence.
"""
print("User inactivity detected - asking if they're still there")
try:
# First warning - ask if they're still there
await session.say("Are you still in there.", allow_interruptions=True)
In your method probably the problem is after tool call llm try to generate response by using tool response. LLM do not have sense of time.billions-lawyer-8588
08/12/2025, 9:57 PM