able-jackal-84140
07/14/2025, 6:47 PMtall-airline-16756
07/14/2025, 6:47 PMtall-airline-16756
07/14/2025, 6:48 PMfrom agent_extensions.handlers import WakeWordHandler
wake_word_handler = WakeWordHandler(
wake_word="sam",
notification_sound_path="path/to/your/notification.wav"
)
agent = VoicePipelineAgent(
# ... other configuration ...
before_llm_cb=wake_word_handler.before_llm_callback
)
When the wake word is detected, the handler automatically plays the notification sound, ensuring immediate feedback even during streaming. For more advanced control, you can also use BackgroundAudioPlayer or send audio frames directly, but the WakeWordHandler approach is the most straightforward for your scenario.
Sources: agent_extensions/agent_extensions/rag/handler.py | examples/voice_agents/background_audio.py | home_assistant/homeautomation.pyable-jackal-84140
07/14/2025, 6:49 PMtall-airline-16756
07/14/2025, 6:50 PMbefore_llm_cb
in a way that makes total sense. Think of it like a friendly backstage helper for the VoicePipelineAgent that gets things ready right before the big performance with the Large Language Model (LLM). Cool, right? 😊
• It helps you trim down conversation history so everything runs smoothly
• You can sneak in extra cool info or context right at the last second
The awesome part is how flexible this callback is! Check out this example where we keep things tidy by making sure the chat context doesn't get too long:
async def truncate_context(assistant: VoicePipelineAgent, chat_ctx: llm.ChatContext):
if len(chat_ctx.messages) > 15:
chat_ctx.messages = chat_ctx.messages[-15:]
agent = VoicePipelineAgent(
...
before_llm_cb=truncate_context,
)
Pro tip: In LiveKit Agents 1.0, they've upgraded this with llm_node
to give you even more awesome customization options.
Sources: VoicePipelineAgent | LiveKit Docs | VoicePipelineAgent | LiveKit Docs | Vision Agent Quickstart | LiveKit Docs | Agents 0.x migration guide | LiveKit Docsable-jackal-84140
07/14/2025, 6:53 PMtall-airline-16756
07/14/2025, 6:54 PMlivekit-examples/agent-demos
repository - not an official plugin, but definitely worth checking out!
Setting it up is super easy. Just run this command:
pip install -e agent_extensions
Pro tip: Make sure you're in the right directory when you do this. The best part? It'll automatically handle all the dependencies like livekit
, python-dotenv
, simpleaudio
, and livekit-agents
for you. How convenient is that?
Sources: LiveKit Agents integrations | LiveKit Docs | Infrastructure & Deployment | livekit/livekit_composite | DeepWiki | agent_extensions/agent_extensions/handlers/wake_word_handler.py | README.md