How to not trigger tool call until the agent stopp...
# ask-ai
s
How to not trigger tool call until the agent stopped speaking
g
To ensure a tool call is not triggered until the agent has stopped speaking, you can use the
agent_stopped_speaking
event. This event can be used to delay the execution of a tool call until the agent has finished its current speech. You can register a callback for this event and place your tool call logic within that callback. Here's a basic example:
Copy code
@assistant.on("agent_stopped_speaking")
def on_agent_stopped_speaking():
    # Place your tool call logic here
    print("Agent has stopped speaking, now triggering tool call.")
    # trigger_tool_call()
This approach ensures that the tool call is only executed after the agent has completed its speech, preventing any interruptions or race conditions. Would you like more details on implementing this in a specific context or with additional features? Sources: - https://livekit-users.slack.com/archives/C07FY8WHGPM/p1729780486.717989 - https://livekit-users.slack.com/archives/C07FY8WHGPM/p1728987953.956549 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.