This message was deleted.
# ask-ai
s
This message was deleted.
t
Thanks for reaching out, Durgesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're right to flag this — you're seeing it because realtime models like Google Gemini Live handle voice-activity/turn detection internally by default, so LiveKit's VAD-based signals (and the older
user_started_speaking
event) won't fire unless you change the setup. What to do next (short checklist): 1. Update your event handling ◦ Listen for
user_state_changed
(states:
speaking
,
listening
,
away
) instead of
user_started_speaking
. 1. Disable the model's automatic activity detection ◦ Set the realtime model config to disable automatic activity detection so LiveKit can control turn detection. 1. Enable local VAD / turn detection and STT plugin ◦ Add a VAD plugin (e.g., Silero) and an STT plugin (e.g., AssemblyAI) or a custom turn detector so
user_away_timeout
and state transitions work. 1. Keep
user_away_timeout
set (e.g., 15s) in
AgentSession
— it will take effect once VAD/turn detection is active. Example (illustrative):
Copy code
session = AgentSession(
  turn_detection=turn_detector.MultilingualModel(),
  vad=silero.VAD.load(),
  stt="assemblyai/universal-streaming",
  llm=google.realtime.RealtimeModel(
    realtime_input_config=types.RealtimeInputConfig(
      automatic_activity_detection=types.AutomaticActivityDetection(disabled=True),
    ),
    input_audio_transcription=None,
  ),
  user_away_timeout=15.0,
)
If you’d like, share your current AgentSession config (redact secrets) and the event listener code — I can point out the exact changes you need. Sources: Agent session | LiveKit docs | Agents v0.x migration guide - Python | LiveKit docs | Agents v0.x migration guide - Node.js | LiveKit Docs | Events and error handling | LiveKit docs | Gemini Live API plugin | LiveKit docs
Thanks — I see you already disabled
automatic_activity_detection
in your
RealtimeInputConfig
, which is the right first step. Next steps to restore
user_away_timeout
and user state events: 1. Listen for
user_state_changed
(states:
speaking
,
listening
,
away
) instead of
user_started_speaking
. 2. Ensure LiveKit handles VAD/turn detection by adding: ◦ a VAD plugin (e.g., Silero) via
vad=...
◦ a turn detector (e.g.,
turn_detection=turn_detector.MultilingualModel()
) ◦ an STT plugin (e.g.,
stt="assemblyai/universal-streaming"
) or set
input_audio_transcription
appropriately 1. Keep
user_away_timeout
set in your
AgentSession
(e.g.,
15.0
). Example placement (illustrative):
Copy code
session = AgentSession(
  turn_detection=turn_detector.MultilingualModel(),
  vad=silero.VAD.load(),
  stt="assemblyai/universal-streaming",
  llm=<your google.beta.realtime.RealtimeModel(...)>,
  user_away_timeout=15.0,
)
If you share your AgentSession initialization (redact keys) and the event-listener code you use, I’ll point out exactly what to add or adjust.
Thanks — I can help with that. You're hitting a known issue where
AudioStream.aclose()
checks
self._processor
even when it was never created, causing the AttributeError. What you can do right now (short, safe fixes): 1. Prefer the factory that ensures initialization:
Copy code
from livekit.rtc import AudioStream

stream = AudioStream.from_track(track, noise_cancellation=None)
1. If you must use the constructor or need a quick workaround, ensure the attribute exists:
Copy code
stream = AudioStream(track)
if not hasattr(stream, "_processor"):
    stream._processor = None
1. Verify plugin/version compatibility: • Make sure
livekit
and any
livekit-plugins-*
packages are matched (same release family). If you want, paste the small snippet where you create the AudioStream (redact secrets) and the exact package versions (
pip show livekit
and
pip show livekit-plugins-*
) and I’ll point out the specific change to make. Sources: Capturing the First Few Seconds of a Call for Processing | Enhanced noise cancellation | LiveKit docs
Thanks — that version list is helpful. Short guidance: 1) Use
AudioStream.from_track(...)
(preferred) or ensure
_processor
exists • Replace any
AudioStream(track)
with:
Copy code
from livekit.rtc import AudioStream
stream = AudioStream.from_track(track, noise_cancellation=None)
or, as a quick workaround after construction:
Copy code
if not hasattr(stream, "_processor"):
    stream._processor = None
2) Upgrade LiveKit if possible • Your
livekit
is 1.0.21 and
livekit-plugins-noise-cancellation
is 0.2.5. This AttributeError is caused by
_processor
not being initialized in some code paths and is fixed in later releases. Please try upgrading
livekit
and related plugins to the latest 1.2.x/1.3.x family so the AudioStream initialization bug is resolved and package families match. 3) Tell me: • Which code you use to create the AudioStream (paste the snippet, redact secrets). • Confirm whether you create it via
from_track
or the constructor and whether you pass any
noise_cancellation
plugin. I’ll point out the exact change to make and verify compatibility with your installed plugin versions.
Thanks — I see what's happening from your trace and package list. Short answer: this is a bug in the LiveKit Python packages you have installed:
AudioStream
is trying to access
self._processor
during internal teardown but that attribute wasn't initialized in your SDK version, which raises the AttributeError. The reliable fixes are: 1) Upgrade LiveKit packages so AudioStream initializes
_processor
correctly: • Run:
Copy code
pip install --upgrade livekit livekit-agents livekit-plugins-noise-cancellation \
       livekit-plugins-silero livekit-plugins-google livekit-plugins-turn-detector
• Aim to move from `1.0.21`/`0.2.5` to the matching 1.2.x / 1.3.x family for
livekit
+ related plugins so package families are aligned. 2) Restart your service after upgrading. If you cannot upgrade immediately, apply this server-side workaround to avoid the crash (patch where the AudioStream object is created internally): • Add a defensive attribute initialization after the AudioStream is constructed:
Copy code
# after stream is created internally
if not hasattr(stream, "_processor"):
    stream._processor = None
You said the code is internal — if you cannot change where it's created, upgrading packages is the recommended path. Also, for the original realtime-model issue (so user states and
user_away_timeout
work): • Disable the model's automatic activity detection in your
RealtimeInputConfig
. • Enable LiveKit VAD/turn detection by adding a VAD plugin (Silero), a turn detector, and an STT plugin (e.g., AssemblyAI). • Listen for
user_state_changed
(states:
speaking
,
listening
,
away
) instead of
user_started_speaking
. Next steps for me to help: • Confirm you can upgrade now and restart the service. If yes, I’ll guide exact version targets if you want. • If upgrade isn’t possible, tell me where you can inject the small
_processor
initialization (or paste the service/agent startup snippet, redacting secrets) and I’ll point exactly where to add it. Sources: Resolving &amp;#34;InvalidState - failed to capture frame&amp;#34; errors in AudioSource | Agents (Python) | livekit/livekit_composite | DeepWiki | Job lifecycle | LiveKit docs | Capturing the First Few Seconds of a Call for Processing
Thanks — I know this is frustrating. You’re still hitting the same internal AttributeError, so let’s narrow this down and get a working path. Quick checklist and next steps: 1) Confirm upgrade completed • What do you get from:
Copy code
pip show livekit
  pip show livekit-agents
  pip show livekit-plugins-noise-cancellation
Paste their Version values (redact nothing else). I need to confirm they actually upgraded to the 1.2/1.3 family. 2) If upgrade is possible, run this exact upgrade command and then restart your service:
Copy code
pip install --upgrade "livekit>=1.2.0" "livekit-agents>=1.3.0" "livekit-plugins-noise-cancellation>=1.3.0" "livekit-plugins-silero>=1.3.0"
Then restart and re-check the trace. Tell me results. 3) If you cannot upgrade now, add a defensive patch at runtime (no source edit required) — run this early in your process before agents start:
Copy code
import livekit.rtc.audio_stream as _as
  if not hasattr(_as.AudioStream, "_processor"):
      # ensure instances created later have the attribute
      _as.AudioStream._processor = None
Add that near your app startup (before LiveKit creates streams). Try this and report whether the traceback stops. 4) If the error persists after upgrade or the patch: • Paste the exact versions from step (1). • Paste your AgentSession creation snippet (redact keys) or the small startup code that initializes agents so I can spot where AudioStream is created. Pick one path: confirm current versions, or try the runtime patch and tell me results — I’ll follow up with the next precise step.
r
is it possible to disable interruption for realtime agents ?
t
Regarding disabling interruption for realtime agents: you cannot disable interruptions when using a RealtimeModel with built-in turn detection. The model manages turn-taking server-side, so
allow_interruptions
in
AgentSession
is ignored in that mode. If you’re using a non-realtime setup (VAD/STT-based turn detection), you can disable interruptions by setting
allow_interruptions=False
on the
AgentSession
. If you need finer control with a realtime model, consider disabling the model’s automatic activity detection and using LiveKit’s VAD/turn-detection stack (Silero + STT/turn detector). That lets LiveKit control interruptions and respects
allow_interruptions
. Would you like steps for switching to that setup or help checking your current configuration? Sources: Turn detection and interruptions | LiveKit Docs | Agents (Node.js) | livekit/livekit_composite | DeepWiki