How do I debug a Livekit python agent?
# ask-ai
g
How do I debug a Livekit python agent?
t
Thanks for reaching out, Jean-Philippe. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To debug a LiveKit Python agent, you can follow these steps: • Run Agent in Development Mode: Start your agent in
dev
mode for development and debugging. Use the command: `python agent.py dev`This mode connects your agent to LiveKit and makes it accessible from anywhere on the internet while providing debugging capabilities. • Use Built-in Debugging Features: The LiveKit agents framework includes several debugging tools: ◦ Asyncio debugging: Enables asyncio debugging with
loop.set_debug(args.asyncio_debug)
. ◦ Slow callback detection: Configures
loop.slow_callback_duration = 0.1
(100ms) and hooks slow callbacks with
utils.aio.debug.hook_slow_callbacks(2)
. ◦ Exception logging: Automatically logs worker failures with
logger.exception("worker failed")
. • Configure Logging: Set up logging using the framework's configuration: `setup_logging(args.log_level, args.devmode, args.console)`You can also define custom logging in your agent code:
Copy code
import logging
logger = logging.getLogger("your_agent_name")
logger.setLevel(<http://logging.INFO|logging.INFO>)
Use Console Mode: For local debugging, run the agent in
console
mode. This keeps the agent local and accessible only within your terminal. • Testing with Playground: Use the Agents playground to test and debug your agent interactively when running in
dev
mode. • Collect Debugging Information: If you need further assistance, gather the following details: ◦ Library version:
pip freeze |grep livekit
◦ Python version:
python --version
◦ Relevant logs with context ◦ Room info (e.g.,
RM_nnnnn
) ◦ Time the issue occurred and timezone ◦ Whether you're using self-hosted or cloud LiveKit Sources: Voice AI quickstart | LiveKit Docs | Voice AI quickstart | LiveKit Docs | livekit-plugins/livekit-plugins-inworld/livekit/plugins/inworld/log.py | Still Have Questions