is it possible to have listening mode on agent? fo...
# ask-ai
g
is it possible to have listening mode on agent? for example, if the user is expected to give a long presentation, so we want to make sure not to interrupt them if they make a pause longer than current endpointing?
t
Thanks for reaching out, Dima. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — this is a great question. You can achieve a “listening mode” so the agent won’t interrupt during long user presentations. There isn’t a single on/off switch named “listening mode,” but you can combine a few LiveKit controls to get the exact behavior you want. Below are three practical approaches you can choose from (or combine), plus supporting knobs to fine‑tune behavior. 1) Disable automatic turn detection (manual mode) • Set the session to
turn_detection="manual"
and take explicit control of turns. • Keep the agent from responding while the user presents by not committing the user turn until the presentation is finished (use
session.commit_user_turn()
when you want the agent to process the audio). • Use
session.input.set_audio_enabled(False)
or similar session-level controls to stop the agent from listening or responding until you re-enable it. 2) Disable interruptions temporarily • Set
allow_interruptions=False
at the start of the presentation so the agent will not interrupt even if endpointing triggers. • When the presentation ends, re-enable interruptions or explicitly interrupt/trigger the agent to respond. • This is useful when you still want automatic turn detection live but need a period where the agent remains silent. 3) Increase endpointing delays • Increase the endpointing timeout (for example, raise
max_endpointing_delay
from its default) so longer pauses aren’t treated as an end-of-turn. • Combine with a smarter turn detector (a semantic/transformer-based detector) that uses context rather than only silence to detect turn ends, which reduces false positives during long pauses. Supporting configuration and strategies • Tune VAD silence thresholds (e.g.,
min_silence_duration
) so short pauses inside sentences don’t register as silence. • Use event hooks such as
user_input_transcribed
to detect presentation patterns (long continuous speech, sentence counts, or keywords like “that’s all”) and only commit when you see an end signal. • If you expect the presenter to explicitly signal the end, allow a UI button or key press to tell the session to commit the turn immediately. • For workflows that need very low latency when returning to interactive mode, prewarm the VAD or keep a lightweight detector running. Which approach fits best depends on how you want control to work: • Want full programmatic control? Use manual turns. • Want to keep automatic behavior but prevent interruptions for periods? Toggle
allow_interruptions=False
. • Want minimal code changes and longer pauses allowed automatically? Increase endpointing delays and tune VAD. If you’d like, tell me: • Are you using automatic or manual turn detection now? • Do users have a way to signal the end of their talk (UI button, verbal cue)? • Do you prefer a code-first solution or a mostly-config change? I can then give concrete code snippets or configuration values tailored to your setup. Sources: Turns overview | LiveKit Documentation | Uninterruptable Agent | LiveKit Documentation | examples/voice_agents | livekit/livekit_composite | DeepWiki | Improving voice AI's turn detection with transformers | Silero VAD plugin | LiveKit Documentation
g
actually none of this works in real life. can enter/exit listening mode be implemented as agent tools?
t
Thanks — I hear your frustration, and yes: you can implement reliable enter/exit “listening mode” as agent tools. That approach is practical in real-world setups because it gives explicit programmatic control instead of relying on VAD/endpointing alone. Below is a concise plan plus example tools and integration ideas you can use right away. What these tools do • Explicitly enable/disable the agent’s audio input so the agent won’t process or interrupt during a presentation. • Work well with manual turn control so you decide when to commit the user’s audio for processing. Minimal example (Python)
Copy code
from livekit.agents import function_tool

@function_tool()
async def enter_listening_mode(self, context):
    # allow the agent to receive user audio but not auto-respond
    context.session.input.set_audio_enabled(True)
    # optionally disable interruptions if you want the agent to stay silent while listening
    context.session.allow_interruptions = False
    return "Entered listening mode."

@function_tool()
async def exit_listening_mode(self, context):
    # stop receiving user audio
    context.session.input.set_audio_enabled(False)
    # re-enable interruptions or explicitly commit the user turn
    context.session.allow_interruptions = True
    await context.session.commit_user_turn()
    return "Exited listening mode and committed user turn."
Recommended setup for reliability • Use
turn_detection="manual"
so endpointing/silence doesn’t prematurely end the presentation. • Use the tools above triggered by: ◦ A frontend button (“Start Presentation” / “End Presentation”), or ◦ A voice keyword you detect separately, or ◦ An external orchestration event. • While in listening mode, keep
set_audio_enabled(True)
but keep the agent from replying until you call
commit_user_turn()
or otherwise trigger processing. • If you still want the agent to monitor for an explicit verbal cue, run a lightweight detector in parallel (not the main turn detector) and only call
commit_user_turn()
when that cue occurs. Why this fixes real-life problems • Avoids false endpointing from natural pauses or noisy environments. • Gives deterministic control to the app or presenter rather than relying on VAD heuristics. • Integrates cleanly with UI/UX (push-to-talk, dedicated presentation mode, admin controls). If you want, I can: • Provide a complete end-to-end example that includes frontend RPCs to trigger these tools. • Show how to combine this with a small keyword detector that auto-exits listening mode on a verbal cue. • Suggest safe defaults for
allow_interruptions
and when to call
commit_user_turn()
. Which would be most helpful: a frontend+agent code sample, or the keyword-detector integration? Sources: Turns overview | LiveKit Documentation | Text and transcriptions | LiveKit Documentation