In the LiveKit Agents tab, I have 11 Active Worker...
# ask-ai
a
In the LiveKit Agents tab, I have 11 Active Workers running. I believe this is causing my calls to be dispatched to dead workers. Is this an issue? How do I go about killing old workers.
➕ 1
t
Thanks for reaching out, Nick. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Regarding your 11 Active Workers and calls going to dead workers — thanks for raising this. I’ll address whether this is a problem and show safe ways to remove old/stale workers. What’s happening • Having many active workers is not inherently bad — LiveKit only dispatches jobs to workers that are healthy and ready. • If a worker crashed or didn’t shut down cleanly it can still appear as “active” in the UI while not actually handling work. That can cause symptoms that look like calls being dispatched to dead workers. What you can do (safe steps) 1. Inspect which workers are actually handling sessions ◦ Use the Agents tab to check session/activity per worker and identify workers with zero recent activity. 1. Graceful restart (preferred) ◦ Run a rolling restart of the agent so workers receive shutdown signals and enter draining mode; active calls finish and workers stop accepting new jobs. ◦ Use the LiveKit CLI commands for your agent if you use the CLI (e.g.,
lk agent restart
/
lk agent deploy
) to perform a controlled restart. 1. Remove stale agent instances ◦ List agents:
lk agent list
◦ Delete stale agent/worker deployments:
lk agent delete --id <agent_id>
◦ Deleting an entire agent deployment ensures old instances are removed and new ones start cleanly. 1. If a worker is unresponsive ◦ Prefer triggering a controlled redeploy/restart so draining completes. If the instance is truly frozen and cannot be drained, deleting the agent deployment and redeploying will restore a clean pool. Quick diagnostic questions • Do you see workers with no active sessions but still marked Active in the UI? • Are you using the LiveKit CLI/agent deployment (CLI, k8s, or other environment)? I can walk you through the exact commands for your environment (CLI, Kubernetes, or custom deploy) once you tell me which you’re using. Would you like that? Sources: Worker lifecycle | LiveKit Docs | Deploying to custom environments | LiveKit Docs | Deploying to production | LiveKit Docs | Agent deployment CLI reference | LiveKit docs
a
When I run
lk agent list
I see this response:
Copy code
Using default project [project-1]
unable to list agents: Error from intermediary with HTTP status code 401 "Unauthorized"
Even though I already authenticated.
t
Thanks — I’m responding about the 401 when running
lk agent list
. Quick checklist to diagnose and fix this: 1. Confirm current project and credentials: ◦ Run
lk project list
and tell me the default project shown. 1. Re-authenticate to refresh credentials: ◦ Run
lk cloud auth
and complete the browser sign-in, then retry
lk agent list
. 1. Check permissions / project linkage: ◦ Ensure the account/API key you authenticated with has agent-management permissions for that project (admin-level access is typically required). 1. If you have a
livekit.toml
in your working directory, the CLI will use it — move or rename it temporarily and retry to rule out a misconfigured file. Please share: • Output of
lk project list
• Whether you used
lk cloud auth
or an API key, and • Whether a
livekit.toml
exists in your current directory I’ll use that to suggest the exact next command or fix. Sources: Deploying to production | LiveKit Docs | Agent deployment CLI reference | LiveKit docs | LiveKit CLI project management | LiveKit docs | SIP APIs | LiveKit docs
a
• Output of
lk project list
All my projects and api keys. I do not want to share that here. • Whether you used
lk cloud auth
or an API key, and I used this and it seemed to work • Whether a
livekit.toml
exists in your current directory I do not see this file
t
Thanks — I’ll help troubleshoot while respecting your privacy. Since you authenticated with
lk cloud auth
, try these targeted checks (no secrets needed): 1. Force-use the project explicitly • Run:
lk agent list --project <project-name-or-id>
◦ Replace with your project identifier you already see locally. This avoids relying on any CLI default. 1. Verify CLI auth state • Run:
lk auth status
◦ Paste the non-sensitive output (it shows which account/project is active, not API keys). 1. Confirm CLI config files won’t override behavior • Check for
livekit.toml
in parent folders:
ls -a ..
(repeat up the path) — you said none in cwd, but a parent file can be used. • Check CLI config:
cat ~/.config/livekit/config.json
(only share whether it references the expected project, not keys). 1. Re-authenticate to refresh scopes • Run
lk cloud auth
again and retry
lk agent list --project <project-id>
. 1. If still 401, try using an explicit API key (temporary) to test permission scope • Create or use an API key with admin/agent permissions in the Cloud Console, then run: ◦
LK_API_KEY=<key> LK_API_SECRET=<secret> lk agent list --project <project-id>
◦ Only run this as a test — don’t paste keys here. If you prefer, tell me the outputs of: •
lk auth status
•
lk agent list --project <project-id>
(project name only) and whether re-running
lk cloud auth
changed the result. I’ll guide the next step based on those results.
a
The output of
lk auth status
is
No help topic for 'auth'. a
t
Thanks — responding about the
No help topic for 'auth'
output and the 401 when running
lk agent list
. Two likely causes: CLI command/version mismatch or stale/insufficient credentials. Try these steps and share the outputs: 1. Check CLI version • Run:
lk --version
• Paste the output. 1. Re-run the correct auth flow • Run:
lk cloud auth
and complete the browser sign-in. Then retry: ◦
lk agent list --project <project-id>
1. Confirm configured projects • Run:
lk project list
• Share the non-sensitive output showing project names/IDs (don’t share keys). 1. If 401 persists, test explicitly with the project flag • Run:
lk agent list --project <project-id>
• Share the exact error text. 1. Optional diagnostic (no secrets) • Check CLI config references:
cat ~/.config/livekit/config.json
and tell me whether it lists the project you expect. Tell me the outputs of steps 1, 3, and 4 and I’ll guide the next action. Sources: Deploying to production | LiveKit Docs | LiveKit CLI project management | LiveKit docs | Voice AI quickstart | LiveKit docs
a
lk --version lk version 2.12.9
t
Thanks — responding to your confirmed CLI version (lk 2.12.9) and the 401 when running
lk agent list
. Since your CLI is current, this is an authentication/authorization or project-selection issue. Please run the following commands and share only the non-sensitive outputs: 1. Ensure a default project is set: • Run:
lk project list
• If your intended project is not marked as default, set it: ◦
lk project set-default <project-id-or-name>
• Then retry:
lk agent list
1. If you prefer to avoid changing defaults, explicitly target the project: •
lk agent list --project <project-id-or-name>
1. Re-authenticate to ensure scopes and linkage are fresh: •
lk cloud auth
(complete the browser sign-in), then retry step 1 or 2. 1. If 401 persists, run: •
cat ~/.config/livekit/config.json
◦ Tell me whether it references the project you expect (do not paste keys). One of these will reveal whether the CLI is pointed at a different project or whether your account lacks agent-management permissions. Tell me the outputs of
lk project list
and
lk agent list --project <project-id>
(error text only) and I’ll guide the exact fix. Sources: Agent deployment CLI reference | LiveKit docs | Analytics API | LiveKit docs | Deploying to production | LiveKit Docs
a
Running cat ~/.config/livekit/config.json gives me an error that the file does not exist
t
Thanks — since no CLI config file exists, let’s verify project selection and re-authenticate explicitly. Please run these steps and share only non-sensitive outputs or simple answers: 1. List projects • Command:
lk project list
• Reply whether your intended project appears and if one is marked Default. 1. If your project is not Default, set it • Command:
lk project set-default <project-id-or-name>
• Then run:
lk agent list
and tell me the exact result (error or list). 1. If your project was already Default or step 2 still gives 401, re-authenticate • Command:
lk cloud auth
• Complete the browser sign-in, then run: ◦
lk agent list --project <project-id-or-name>
• Tell me the exact error text if it still fails. 1. Check account permissions (no secrets) • In the Cloud Console, confirm the account/API key you used has admin/agent-management permissions for that project. Tell me if you can confirm that. If you prefer, run step 1 now and paste the non-sensitive output; I’ll tell you the exact next command based on that.