A specialized voice AI agent built with LiveKit Agents for Python and LiveKit Cloud. This McDonald's Drive-Thru Agent takes customer orders using real menu data and natural language processing.
- McDonald's Drive-Thru Voice AI Agent
This repository demonstrates how to build a specialized voice AI agent using LiveKit. The Drive-Thru Agent (src/agent.py) handles customer orders with menu validation, item search, and order tracking capabilities.
- Python 3.11 or later
- uv package manager
- LiveKit Cloud account (free tier available)
- API keys for:
- OpenAI (for LLM)
- AssemblyAI (for STT)
- Cartesia (for TTS)
Clone the repository and install dependencies:
git clone <repository-url>
cd lk-agent-1
uv syncIMPORTANT: This project uses uv for dependency management. Always use uv run to execute commands (e.g., uv run python src/agent.py). Do not manually activate virtual environments - uv run handles this automatically.
-
Sign up for LiveKit Cloud
-
Copy the example environment file:
cp .env.example .env.local
-
Fill in the required keys in
.env.local:LIVEKIT_URLLIVEKIT_API_KEYLIVEKIT_API_SECRETOPENAI_API_KEYASSEMBLYAI_API_KEYCARTESIA_API_KEY
You can also use the LiveKit CLI to automatically load environment variables:
lk cloud auth
lk app env -w -d .env.localBefore running the agent for the first time, download required models:
uv run python src/agent.py download-filesThis automatically downloads files for all registered LiveKit plugins:
- Silero VAD (Voice Activity Detection) model
- Multilingual turn detector model
- Any other plugin-required models
The Drive-Thru Agent is a specialized voice AI that:
- Takes customer orders for McDonald's menu items
- Searches and validates items against a real McDonald's menu
- Handles item modifiers (add-ons, substitutions)
- Confirms each item as it's added
- Reads back the complete order
- Saves orders as JSON files for processing
The Drive-Thru Agent consists of several components:
-
DriveThruAgent (
src/drive_thru_agent.py)- Orchestrates the ordering conversation
- Defines the agent's persona and instructions
- Manages order state via
OrderStateManager - Provides tools for adding/confirming orders
-
DriveThruLLM (
src/drive_thru_llm.py)- Wraps the base LLM (e.g., GPT-4)
- Intercepts chat requests to inject menu context
- Searches menu based on keywords in user messages
- Reduces hallucination by grounding LLM in actual menu items
-
MenuProvider (
src/menu_provider.py)- Loads McDonald's menu from JSON
- Provides search functionality
- Returns structured menu items (categories, modifiers)
-
OrderStateManager (
src/order_state_manager.py)- Tracks order items during conversation
- Saves completed orders to JSON files
- One instance per session
Test the agent directly in your terminal using LiveKit's built-in console:
uv run python src/agent.py consoleConsole Options:
--text: Start in text mode instead of audio mode--input-device DEVICE: Select specific input audio device--output-device DEVICE: Select specific output audio device--list-devices: Show all available audio devices--record: Record the session to disk
Examples:
# Text-based chat mode (no audio)
uv run python src/agent.py console --text
# List available audio devices
uv run python src/agent.py console --list-devices
# Use specific microphone
uv run python src/agent.py console --input-device "USB Microphone"
# Record the session
uv run python src/agent.py console --recordInteractive Features:
- Press
Ctrl+Tduring a session to toggle between audio and text modes - In audio mode, see real-time frequency visualization of your microphone input
- Automatic device selection if not specified
This mode is perfect for:
- Quick testing and debugging
- Trying out the ordering flow
- Experimenting with menu items
- Testing without a frontend application
Run the agent with a LiveKit connection for testing with real voice:
uv run python src/agent.py devThis mode:
- Connects to LiveKit Cloud
- Supports frontend applications
- Includes noise cancellation
- Enables real voice interactions
For production deployment:
uv run python src/agent.py startThis is the production-ready entry point used in Docker deployments.
The McDonald's menu is stored as structured Pydantic models in menus/mcdonalds/:
- Menu Structure -
transformed-data/menu-structure-2026-01-21.json - Pydantic Models -
models.pyMenu- Complete menu with categoriesItem- Individual menu item with modifiersModifier- Item variations (e.g., "Extra Cheese", "No Pickles")
Categories include:
- Breakfast
- Beef & Pork
- Chicken & Fish
- Snacks & Sides
- Beverages
- Coffee & Tea
- Desserts
- Smoothies & Shakes
Completed orders are saved to the orders/ directory as JSON files:
{
"session_id": "abc123",
"items": [
{
"item_name": "Big Mac",
"category": "Beef & Pork",
"modifiers": ["Extra Cheese", "No Pickles"]
}
],
"timestamp": "2026-01-22T10:30:00Z"
}src/
├── agent.py # Drive-Thru Agent CLI (main entry point)
├── config.py # Pydantic configuration models
├── factories.py # Creates STT/LLM/TTS instances
├── session_handler.py # Session orchestration
├── drive_thru_agent.py # Drive-Thru Agent implementation
├── drive_thru_llm.py # Menu-aware LLM wrapper
├── menu_provider.py # Menu search and loading
├── order_state_manager.py # Order tracking
└── tools/
└── order_tools.py # Order management tools
menus/mcdonalds/
├── models.py # Pydantic menu models
├── transformed-data/ # Menu JSON files
└── raw-data/ # Original menu data
tests/
├── conftest.py # Shared pytest fixtures
├── test_drive_thru_agent.py # Agent tests
├── test_menu_models.py # Menu model tests
└── ...
Run all tests:
uv run pytestRun specific test file:
uv run pytest tests/test_drive_thru_agent.py -vRun with coverage:
uv run pytest --cov=src --cov-report=htmlFormat code with ruff:
uv run ruff formatLint code:
uv run ruff checkFix linting issues:
uv run ruff check --fixThis project includes a Makefile for common tasks:
make help # Show all available commands
make console # Run drive-thru agent in console mode
make dev # Run drive-thru agent in dev mode
make test # Run all tests
make format # Format code
make lint # Lint code
make download-files # Download model filesReview implementation plans for quality and executability before execution:
# Review a plan file
/review_plan plan/2026-01-23-feature-name.md
# Review a multi-file plan
/review_plan plan/2026-01-23-feature-name/
# Interactive mode
/review_planThe review agent analyzes plans across 5 dimensions:
- Accuracy - Technical correctness and validity
- Consistency - Internal consistency and conventions
- Clarity - Clear, unambiguous instructions
- Completeness - All necessary steps and context
- Executability - Can agents execute without intervention?
Output: Review saved to *.REVIEW.md with executability score (0-100) and detailed recommendations.
Note: Reviews are advisory only. No changes are made to original plans.
This codebase uses dependency injection (DI) to construct components:
- Configuration -
src/config.py(Pydantic v2 models, env-driven) - Construction -
src/factories.py(builds STT/LLM/TTS) - Wiring -
src/agent.py(creates app + server) - Runtime -
src/session_handler.py(manages sessions)
No custom adapters or protocols are used - components are constructed directly using LiveKit's concrete types.
This project uses Pydantic v2 for all data models:
- Runtime validation
- JSON serialization/deserialization
- Schema generation
- Environment variable integration
- Better IDE support
See AGENTS.md for detailed guidelines on when to use Pydantic vs dataclasses.
Get started with pre-built frontend applications:
| Platform | Repository | Description |
|---|---|---|
| Web | agent-starter-react |
React & Next.js web app |
| iOS/macOS | agent-starter-swift |
Native iOS, macOS, visionOS |
| Flutter | agent-starter-flutter |
Cross-platform mobile |
| React Native | voice-assistant-react-native |
React Native & Expo |
| Android | agent-starter-android |
Native Android (Kotlin) |
| Web Embed | agent-starter-embed |
Embeddable widget |
| Telephony | Documentation | Phone integration |
See the complete frontend guide for advanced customization.
This project includes a production-ready Dockerfile. To deploy:
-
Build the Docker image:
docker build --platform linux/amd64 --no-cache -t drive-thru-agent . -
Deploy to LiveKit Cloud or your preferred platform
See the deploying to production guide for details.
This project works with coding agents like Cursor and Claude Code.
Install the LiveKit Docs MCP server for best results:
For Cursor:
For Claude Code:
claude mcp add --transport http livekit-docs https://docs.livekit.io/mcpFor Codex CLI:
codex mcp add --url https://docs.livekit.io/mcp livekit-docsFor Gemini CLI:
gemini mcp add --transport http livekit-docs https://docs.livekit.io/mcpThe project includes a complete AGENTS.md file with coding guidelines. See https://agents.md to learn more.
This project is licensed under the MIT License - see the LICENSE file for details.