How mivi-dev-org/custom-livekit-agents works
LiveKit Agents is a Python framework for server-run, real-time conversational participants. The main path is worker scheduling and dispatching a job, the user entrypoint connecting to a room, and an AgentSession coordinating voice input, agent/LLM and tool behavior, then speech output to the room. Provider plugins supply model integrations; the framework also exposes realtime models, MCP, semantic turn detection, and telemetry. Edges reflect README-described flow and its example; unsampled subsystems are included where documented, without asserting internal calls not shown in the excerpts.
Main entry points: agent_session.py Agent session · llm.py LLM interface · agent.py Agent instructions · job.py Job context
Components 21
Worker runtime
- Worker scheduler
livekit-agents/livekit/agents/worker.py - Job context
livekit-agents/livekit/agents/job.py - App CLI
livekit-agents/livekit/agents/cli/cli.py
Conversation runtime
- Agent instructions
livekit-agents/livekit/agents/voice/agent.py - Agent session
livekit-agents/livekit/agents/voice/agent_session.py - Room audio I/O
livekit-agents/livekit/agents/voice/room_io/room_io.py - Voice generation
livekit-agents/livekit/agents/voice/generation.py - Voice activity
livekit-agents/livekit/agents/vad.py
Models and tools
- Speech recognition
livekit-agents/livekit/agents/stt/stt.py - LLM interface
livekit-agents/livekit/agents/llm/llm.py - Chat context
livekit-agents/livekit/agents/llm/chat_context.py - Function tools
livekit-agents/livekit/agents/llm/tool_context.py - Realtime models
livekit-agents/livekit/agents/llm/realtime.py - Speech synthesis
livekit-agents/livekit/agents/tts/tts.py
Integrations and observability
- OpenAI provider
livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py - Provider plugins
livekit-plugins - MCP integration
livekit-agents/livekit/agents/llm/mcp.py - Semantic turn detection
livekit-plugins/livekit-plugins-turn-detector/livekit/plugins/turn_detector/base.py - Metrics and traces
livekit-agents/livekit/agents/telemetry
Other components
- Room participant
- LiveKit room service
Connections 24
- Room participant → LiveKit room service: joins room
README.md - App CLI → Worker scheduler: runs app
README.md - Worker scheduler → Job context: dispatches job
README.md - Job context → LiveKit room service: connects room
README.md - Job context → Agent session: starts session
README.md - Agent session → Agent instructions: runs agent
README.md - Agent session → Room audio I/O: uses room
- Room audio I/O → LiveKit room service: exchanges media
- Room participant → Room audio I/O: sends voice
- Agent session → Voice activity: configures VAD
README.md - Agent session → Speech recognition: configures STT
README.md - Agent session → LLM interface: configures LLM
README.md - Agent session → Speech synthesis: configures TTS
README.md - Agent instructions → LLM interface: generates replies
README.md - LLM interface → Chat context: uses context
livekit-agents/livekit/agents/llm/llm.py - Agent instructions → Function tools: defines tools
README.md - Agent session → Voice generation: generates speech
- Voice generation → Speech synthesis: requests synthesis
- OpenAI provider → LLM interface: implements interface
livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.py - Provider plugins → Speech recognition: provides integrations
- Provider plugins → Speech synthesis: provides integrations
- Agent instructions → MCP integration: uses MCP tools
- Agent session → Semantic turn detection: supports detection
- LLM interface → Metrics and traces: emits metrics
livekit-agents/livekit/agents/llm/llm.py