Lesson 2 / Unit 1: LiveKit Foundations
Rooms and Jobs
For a simple one-agent call, room, participant and job IDs link the media path to the worker. Interpret counts against your dispatch and warm-pool settings. The LiveKit object model, mapped to a real voice call.
One phone call to your agent is four kinds of object in LiveKit: a room, two participants, a track from each, and one job.
Every API call, every webhook, and every debugging session is spoken in those four words. Learn them against a single voice call and you can read any LiveKit log line, and you will also know the one mapping that turns a vague “something is leaking” into a specific bug report.
Room Boundaries
A room is a named session. Participants in the same room exchange media, and participants in different rooms never do, so for a voice agent one phone call is one room.
Rooms are created in one of two ways. Your backend can create them explicitly through the API, or the server creates one implicitly when the first participant joins (room cleanup follows the configured empty and departure timeouts).
That second path is convenient and slightly dangerous. A typo in a room name does not fail: it quietly creates a new room, and whoever joins it waits for participants who went somewhere else.
Participant Identity
A participant is one connected identity in a room, holding a connection to the SFU, and in a voice call there are usually exactly two:
- The caller. A browser user joins as a participant directly. A phone caller arrives as a participant created by the SIP service, which bridges the carrier’s audio into the room.
- The agent. Your agent joins as another participant, the same way a browser would.
Each participant carries an identity string and metadata you control. That metadata is where the caller number and the campaign ID belong, and because you set it at creation, everything downstream (transcripts, billing, debugging) joins on it.
Audio Tracks
A track is one audio or video stream that a participant publishes. Other participants subscribe to it. Nothing flows until someone subscribes.
Here is what a voice call looks like in tracks:
- The phone caller publishes one audio track.
- Your agent subscribes to it, and that is the audio your STT hears.
- The agent publishes its own audio track: the TTS output.
- The caller’s side subscribes to the agent’s track, and that is what the caller hears.
Subscriptions are the unit of media routing. Selective subscription is how large rooms stay cheap, because a participant only receives what it asked for. In a two-party voice call you rarely think about it. Then one subscription goes missing, and the call is one-way.
Agent Dispatch
A job is the agents framework’s unit of work. When a room needs an agent, the server dispatches a job to a registered worker, which spawns a process that joins the room and runs your entrypoint.
Dispatch can be automatic (every new room gets an agent) or explicit, where your backend or the caller’s access token names which agent to send. LiveKit’s agent dispatch guide recommends explicit dispatch for most applications, because it lets you pass job metadata to the agent. The job lifecycle docs cover what happens inside the process after that.
The job, rather than the room, is what the worker tier counts and schedules on, and that distinction becomes very concrete in the worker lifecycle lesson, where load reporting and draining are all per job.
One call is one room. The caller and the agent each publish one audio track and subscribe to the other’s. The job path we highlight is the one the worker tier counts.
Lifecycle Counts
For this one-agent-per-call design, active jobs should follow active calls. Raw process and room counts need not match: idle processes are prewarmed, empty rooms can wait for cleanup, and other designs dispatch multiple agents. Join records by IDs and check the expected transitions.
When they stop matching, the mismatch tells you where to look:
| What you see | What it usually means |
|---|---|
| A room with no job | Dispatch never happened, or no worker accepted it |
| A job outliving its room | The job never reported that it finished |
| More processes than jobs | Processes are not exiting after the call ends |
Unexpected lifecycle differences deserve investigation. Account for warm processes, room cleanup timers and dispatch mode before calling them leaks.
Unit 3 has two lessons on exactly those cases: the shutdown leak is a job outliving its room, and the load threshold is a worker that stays registered but stops being offered jobs.
Before your first production call
Spend ten minutes on metadata design on day one, because the participant and room metadata you attach at creation is what every downstream system (transcripts, billing, debugging) joins on. Skip it and you end up matching calls to CRM records by timestamp, which fails exactly when volume is high enough to matter.
Next: compare hosting choices before running your first agent.
Common questions
What is the difference between a LiveKit room and an agent job?
A room is the session where participants exchange media. A job is the agents framework unit of work: the server dispatches it to a registered worker, which spawns a process that joins the room. A simple voice agent often uses one job per room, but multi-agent designs can use more. Workers schedule jobs, not rooms.
Where should the caller number go in LiveKit?
In participant or room metadata, set when the participant or room is created. Transcripts, billing and debugging all join on that metadata, so decide its shape before the first production call.
We do this work for teams shipping voice agents: Self-Hosted Voice Agent .
Edit this lesson on GitHub ↗Discussion
Questions, corrections and war stories welcome. Sign in with GitHub to comment.