square-activity-46232
02/27/2026, 8:07 PMtall-airline-16756
02/27/2026, 8:08 PMtall-airline-16756
02/27/2026, 8:08 PMagent_name in the agent code (this is not set in the LiveKit Cloud UI).
• After naming an agent, dispatch jobs explicitly to that name via the CLI, API, or by embedding the dispatch in a participant token.
How to add a name to an agent
• The agent’s human-friendly name is set in your agent code using the agent_name parameter (it’s not added from the Cloud UI).
• Example patterns:
◦ Python: @server.rtc_session(agent_name="my-telephony-agent")
◦ Node.js: new ServerOptions({ agentName: "my-telephony-agent" })
• Important: setting agent_name disables automatic dispatch for that agent. The agent will only be assigned via explicit dispatch.
How to specify which agent receives a dispatched job
• Once the agent has a name, you can target it explicitly:
1. CLI
◦ Example:
lk dispatch create \
--agent-name my-telephony-agent \
--room my-room \
--metadata '{"user_id":"12345"}'
1. API (programmatic)
◦ Python example:
dispatch = await lkapi.agent_dispatch.create_dispatch(
api.CreateAgentDispatchRequest(
agent_name="my-telephony-agent",
room="my-room",
metadata='{"user_id":"12345"}'
)
)
• Node.js example (similar parameters via SDK client).
1. Dispatch on participant join (token-based)
◦ Embed the agent dispatch in the participant’s token so the agent is dispatched automatically when the participant joins:
▪︎ Example flow: include a RoomConfiguration with agents=[RoomAgentDispatch(agent_name="my-telephony-agent")] in the token generation step.
Additional notes
• The Cloud-created “id” you see for deployments is the deployment slot identifier; agent_name is the logical identifier you use for routing and recognition.
• You can give the same agent_name to multiple agent instances for load distribution — dispatching to that name will be balanced across instances that share it.
If you want, tell me:
• Which language/runtime you’re using (Python or Node.js) and I’ll provide a copy-paste snippet for your agent and for creating a dispatch in that language.
• Whether you want dispatch triggered from the server (CLI/API) or embedded in participant tokens, and I’ll show the exact steps. Sources: Agent dispatch | LiveKit Documentationsquare-activity-46232
02/27/2026, 9:27 PMtall-airline-16756
02/27/2026, 9:27 PMagent_name dynamically at runtime using deployment-specific configuration rather than hard-coding it.
Quick options
• Use an environment variable (most common).
• Use a config file specific to each deployment.
• Pass the name as a startup/CLI flag from your deployment system.
How that looks in practice 1) Environment variable (recommended)
• Set an env var in each deployment: e.g., AGENT_NAME=dev-agent for your dev deployment and AGENT_NAME=prod-agent for production.
• Read that env var when you initialize the agent.
Example patterns:
• Python:
import os
AGENT_NAME = os.getenv("AGENT_NAME", "default-agent")
@server.rtc_session(agent_name=AGENT_NAME)
async def my_agent(ctx: JobContext):
...
• Node.js:
const agentName = process.env.AGENT_NAME || "default-agent";
const opts = new ServerOptions({ agentName });
2) Config file or secrets manager
• Keep environment-specific config (JSON/YAML) or use your secrets manager. Load the config at startup and pass the value into the same agent_name parameter.
3) Startup flag from deploy tooling
• If your orchestrator (Kubernetes, Docker compose, CI/CD) supports startup args, pass the agent name as a flag and consume it in your app.
Important behavior to remember
• When you set agent_name, the agent is only assigned via explicit dispatch. That means you must dispatch to dev-agent or prod-agent explicitly (CLI, API, or token-based dispatch).
• You can deploy multiple instances with the same agent_name for load balancing, or use unique names per instance if you need exact targeting.
Next step Which runtime are you using (Python or Node.js) and how do you deploy (Docker, Kubernetes, Vercel, etc.)? I’ll give a copy-paste snippet and an example deploy config for your environment.