mastra-ai/mastra · error

@mastra/livekit: voice activity detection requires '@livekit

Error message

@mastra/livekit: voice activity detection requires '@livekit/agents-plugin-silero'. Install it, pass your own `vad` instance, or set `vad: false`.

What it means

createLiveKitWorker uses the Silero VAD plugin for voice activity detection by default, loading '@livekit/agents-plugin-silero' via dynamic import. When that import fails (package not installed), it throws with the original import error attached as `cause`, and suggests installing it, supplying your own `vad`, or disabling VAD.

Source

Thrown at integrations/livekit/src/worker.ts:215

  /**
   * Voice-pipeline observability. When the Mastra instance has observability configured, each
   * session opens a `voice call` trace: LiveKit's STT, TTS, end-of-utterance, VAD, and LLM
   * latency metrics become child spans, and every turn's Mastra agent run nests under the call,
   * which closes with a token/audio usage roll-up. Defaults to `true`; pass `false` to disable.
   */
  observability?: boolean;
  inputOptions?: Parameters<voice.AgentSession['start']>[0]['inputOptions'];
  outputOptions?: Parameters<voice.AgentSession['start']>[0]['outputOptions'];
  /** Called after the session starts — attach event listeners, trigger replies, etc. */
  onSessionStart?: (args: SessionStartArgs) => void | Promise<void>;
}

async function loadSileroVad(): Promise<VAD> {
  let silero;
  try {
    silero = await import('@livekit/agents-plugin-silero');
  } catch (error) {
    throw new Error(
      "@mastra/livekit: voice activity detection requires '@livekit/agents-plugin-silero'. " +
        'Install it, pass your own `vad` instance, or set `vad: false`.',
      { cause: error },
    );
  }
  return silero.VAD.load();
}

async function loadTurnDetector(kind: 'multilingual' | 'english'): Promise<TurnDetectionSetting> {
  let plugin;
  try {
    plugin = await import('@livekit/agents-plugin-livekit');
  } catch (error) {
    throw new Error(
      `@mastra/livekit: turnDetection '${kind}' requires '@livekit/agents-plugin-livekit'. ` +
        "Install it or use a built-in mode like 'vad' or 'stt'.",
      { cause: error },
    );

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Install @livekit/agents-plugin-silero (pnpm add @livekit/agents-plugin-silero).
  2. Pass your own VAD instance via the `vad` option to createLiveKitWorker.
  3. Explicitly set `vad: false` in createLiveKitWorker options to disable voice activity detection.
  4. Check the error's `cause` for the underlying import failure if the package is installed (e.g. bundler resolution issues).

Example fix

// before
createLiveKitWorker({ mastra, workflow: 'voiceFlow' }); // silero not installed
// after
pnpm add @livekit/agents-plugin-silero
createLiveKitWorker({ mastra, workflow: 'voiceFlow' });
// or
createLiveKitWorker({ mastra, workflow: 'voiceFlow', vad: false });
Defensive patterns

Strategy: fallback

Validate before calling

let sileroAvailable = true;
try { await import('@livekit/agents-plugin-silero'); } catch { sileroAvailable = false; }
if (!sileroAvailable && options.vad !== false && !options.vad) {
  console.warn('silero plugin missing; set vad:false or install @livekit/agents-plugin-silero');
}

Try / catch

let workerOptions = { mastra, workflow: 'voiceFlow' };
try {
  await import('@livekit/agents-plugin-silero');
} catch {
  workerOptions = { ...workerOptions, vad: false }; // graceful fallback
}
createLiveKitWorker(workerOptions);

Prevention

When it happens

Trigger: Calling createLiveKitWorker with vad enabled/default while @livekit/agents-plugin-silero is not installed in the project.

Common situations: Fresh checkout without the optional peer dependency installed; pnpm strict node_modules hiding transitive deps; VAD left on default after trimming dependencies; bundlers failing to resolve the optional dynamic import.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/d5b70823f09c6b62. Report an issue: GitHub.