How do I make the agent go silent (not listen to a...
# ask-ai
p
How do I make the agent go silent (not listen to audio input, not produce output) during a function_call? I want to .say something, then go silent until I can end the call. If there are other background tasks using .say; those should stop immediatly.
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hello! Our team is operating on reduced capacity over the holidays, so our responses may be delayed. If your issue is critical/urgent, please react to your original message above with the ‼️ emoji and your issue will be escalated with our team. Happy Holidays!
Thanks — I’ve got you. You want the agent to say something, then be completely silent (no listening, no speaking) for the duration of a function call, and you want any background
.say()
activity to stop immediately. Here’s a concise pattern that accomplishes that. 1) Say the short message (optional)
Copy code
await context.session.say("Processing, please wait...", allow_interruptions=False)
2) Immediately stop all speech output (ongoing + queued)
Copy code
context.session.interrupt()
3) Disable audio input so the agent stops listening
Copy code
context.session.input.set_audio_enabled(False)
4) Cancel any background
.say()
tasks you launched
Copy code
if hasattr(self, "status_task") and not self.status_task.done():
    self.status_task.cancel()
5) Do your long-running work
Copy code
await long_running_operation()
6) When finished, re-enable input or end the call
Copy code
context.session.input.set_audio_enabled(True)   # if you want to resume listening
# or end the call
await context.ctx.room.disconnect()
Notes/tips •
session.interrupt()
cancels ongoing and queued
.say()
calls immediately. • Use task references (e.g.,
status_task
) so you can cancel background tasks; cancelling the task prevents further
.say()
calls. • If you never want the agent to speak during the function, omit the initial
say()
and call
interrupt()
+ disable input immediately. If you want, share a short snippet of how you start background status updates (how you create the
.say()
tasks) and I’ll show exactly where to track and cancel them. Sources: Text and transcriptions | LiveKit docs | examples/voice_agents | livekit/livekit_composite | DeepWiki | External data and RAG | LiveKit docs
p
the .say that happens at the background are in a loop. If I interrupt, is it going to block any new .say or not?
t
Good question — thanks for clarifying which case you mean. No,
session.interrupt()
only cancels the current and queued speech; it does NOT block future
session.say()
calls. If your background loop keeps calling
.say()
, it can schedule new speech after the interrupt. To prevent the loop from producing more speech, stop or control the loop itself. Two common options: • Cancel the background task:
Copy code
if not status_task.done():
    status_task.cancel()
• Use a shared flag the loop checks before calling `.say()`:
Copy code
silent = True  # set when entering silent mode

while not stopped:
    if not silent:
        await session.say("status update")
    await asyncio.sleep(1)
Combine with
session.interrupt()
and
session.input.set_audio_enabled(False)
to immediately stop ongoing speech, stop listening, and ensure no further
.say()
runs. Sources: examples/voice_agents | livekit/livekit_composite | DeepWiki | Turns overview | LiveKit docs | Tool definition and use | LiveKit docs