What is the difference between Agent and AgentSess...
# ask-ai
b
What is the difference between Agent and AgentSession classes?
t
Thanks for reaching out, aile. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The Agent and AgentSession classes serve different but complementary roles in the LiveKit Agents framework: Agent Class: • Represents the AI logic and behavior of your voice agent. • Defines the personality, instructions, and capabilities of your AI assistant. • Can include custom prompts, tools, and other logic. • Multiple agents can exist within a single session for workflows and handoffs. AgentSession Class: • Manages the runtime infrastructure for the agent. • Handles media streams, speech/LLM components, and tool orchestration. • Coordinates components like STT, TTS, VAD, and LLM interactions. • Manages turn detection, interruptions, and technical aspects of the conversation. Relationship: • The
AgentSession
acts as a container that runs one or more
Agent
instances. • Each session requires at least one
Agent
to orchestrate. • Typically, you create an
Agent
(defining AI behavior), then an
AgentSession
(setting up the technical infrastructure), and start the session with the agent. This separation allows you to focus on the AI logic in the
Agent
class while letting
AgentSession
handle the complex real-time media processing and coordination. Sources: livekit-agents/livekit/agents/__init__.py | Building voice agents | LiveKit Docs | Workflows | LiveKit Docs | Agents Core Architecture | livekit/livekit_composite | DeepWiki