m
hi
t
Thanks for reaching out, aigentzi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi — how can I help you today? If you’re reaching about LiveKit, tell me what you’re trying to do (e.g., SDK/room issues, connection errors, account/billing, or feature questions) and any relevant details like SDK/platform (web/iOS/Android), room ID, error messages, or steps to reproduce.
m
how do we createa n agent subdomain ? at livekit cloud
t
You're asking how to create an agent subdomain on LiveKit Cloud — short answer: you don't create one separately. Agents inherit your project's subdomain automatically. What to do: 1. Create a LiveKit Cloud project (you'll get a project subdomain like
yourproject.livekit.cloud
). 2. In
livekit.toml
set the project subdomain under
[project]
(e.g.,
subdomain = "yourproject"
). 3. Deploy your agent with the LiveKit CLI (for example
lk agent create
) — the agent is automatically associated with the project subdomain. If you need SIP endpoints, construct them with your project subdomain and region:
{sip_subdomain}.{region}.sip.livekit.cloud
. Would you like steps for creating the project, an example
livekit.toml
, or the exact
lk
CLI command to run? Sources: Mini tutorial: setting up a LiveKit Cloud project | Deploying to production | LiveKit Docs | SIP cloud and region pinning | LiveKit docs
m
1. What's the correct import for RoomConfiguration and RoomAgentDispatch? Is it from livekit.protocol import room or something else? 2. What are the correct/required parameters for RoomAgentDispatch? We're using: ◦ agent_name="cloud-english-teacher" ◦ agent_id="CA_e7hLTus66nKZ" ◦ metadata=json.dumps({"persona": "English Teacher"}) 3. Here's our current code that's failing in a Vercel serverless function: python What's wrong with this code? The agent is deployed to LiveKit Cloud and works when dispatched manually." from livekit import api from livekit.protocol import room as proto_room room_config = proto_room.RoomConfiguration( agents=[ proto_room.RoomAgentDispatch( agent_name="cloud-english-teacher", agent_id="CA_e7hLTus66nKZ", metadata=json.dumps({"persona": "English Teacher"}), ) ] ) token = ( api.AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET) .with_identity(identity) .with_name("Student") .with_grants(grants) .with_room_config(room_config) .to_jwt() )
t
Thanks — I’ll answer each point and show the minimal corrected code. 1) Correct imports • Import
RoomConfiguration
and
RoomAgentDispatch
from
livekit.api
, not
livekit.protocol
. 2) Required parameters for RoomAgentDispatch • Only
agent_name
is required. •
metadata
is optional and should be a string (JSON is fine). •
agent_id
is not a valid parameter for
RoomAgentDispatch
and will cause errors. 3) What’s wrong with your code & corrected snippet • Problems: you imported from
livekit.protocol
and passed
agent_id
. • Fix: import from
livekit.api
and remove
agent_id
. Corrected example:
Copy code
from livekit import api
from livekit.api import RoomConfiguration, RoomAgentDispatch
import json

room_config = RoomConfiguration(
    agents=[
        RoomAgentDispatch(
            agent_name="cloud-english-teacher",
            metadata=json.dumps({"persona": "English Teacher"})
        )
    ]
)

token = (
    api.AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET)
    .with_identity(identity)
    .with_name("Student")
    .with_grants(grants)
    .with_room_config(room_config)
    .to_jwt()
)
If you still see errors when running this in your Vercel function, please share the exact error message and the SDK version you’re using so I can help further. Would you like the exact
lk
CLI command to verify the agent name? Sources: Agent dispatch | LiveKit docs | Authentication | LiveKit docs | SIP dispatch rule | LiveKit docs | server-sdk-kotlin | livekit/livekit_composite | DeepWiki
m
any idea why agent bnot joining : app.js:117 API Response: {token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiU…MwM30.K09tZIHSz8pbA86Zn5esLsLjh1ovAG-VgJapHjUp6io', room_name: 'lesson-8654951a', url: 'wss://turbo-ms4yz8cm.livekit.cloud', persona: 'Taxi Driver', agent_status: 'enabled'} app.js:189 🔗 Connecting to: wss://turbo-ms4yz8cm.livekit.cloud app.js:190 🎫 Token (first 50 chars): eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiU... app.js:129 ✅ Connected to room app.js:193 ✅ Room.connect() completed utils.ts:178 disconnect from room {room: 'lesson-8654951a', roomID: 'RM_JYZ63nNg5Fpe', participant: 'student-3df6ca4d', pID: 'PA_BDWibGQVfUN5'}
t
Thanks — I looked at your logs showing the client connects successfully but the agent never joins. Quick checklist and targeted questions to find the root cause: What to check (likely causes) • Agent name mismatch: confirm the agent’s registered name exactly matches the
agent_name
you used (case-sensitive). • Agent not running/registered: ensure the agent server is started and shows as registered with LiveKit Cloud. • Dispatch method: confirm whether you expect automatic dispatch on join (token-based) or explicit dispatch via API. If the agent server has an
agent_name
set, automatic dispatch is disabled and you must explicitly dispatch. • Token contents: decode the JWT and confirm it contains
room_config.agents
with your
RoomAgentDispatch
. If it’s missing, the agent won’t be dispatched on join. • Agent server logs: check for any errors or incoming dispatch requests that were rejected. Please provide • How the agent is deployed (LiveKit Cloud CLI, Cloud UI, or self-hosted) • Whether you intend token-based (automatic) dispatch or API/explicit dispatch • The exact agent name you registered (copy/paste) • A decoded JWT payload (redact secrets) or confirm presence of
room_config.agents
• Agent server logs or any error lines you see Send those and I’ll point to the next steps (fix token, dispatch via API, or check agent registration) and give the exact commands/snippets you’ll need. Sources: SIP troubleshooting guide | LiveKit docs | Agent server | LiveKit docs | Agent dispatch | LiveKit docs | SIP dispatch rule | LiveKit docs
m
livekit cloud agent is running cloud-english-teacher CA_e7hLTus66nKZ , we expet agent t start talking when use er presses srtart lesson button on htmpl page
t
Thanks — since your agent server is running (name = "cloud-english-teacher", id = CA_e7hLTus66nKZ) and you expect the agent to start talking when the user clicks "start lesson", the most likely issue is that the agent never receives a dispatch request. Quick checklist and next steps to get it working: 1) Confirm dispatch method • Do you intend token-based automatic dispatch on join, or to explicitly dispatch the agent when the Start button is clicked? • If the agent server was created with an
agent_name
set, automatic dispatch is disabled. That means clicking Start must trigger an explicit dispatch call to LiveKit. 2) If you want explicit dispatch on button click (recommended given your description) • On Start button pressed, have your server call CreateAgentDispatch (LiveKit API) for that room with
agent_name="cloud-english-teacher"
and optional
metadata
. • Example flow: a. Client clicks Start -> hits your backend endpoint (authenticated). b. Backend calls the LiveKit CreateAgentDispatch API for room "lesson-..." specifying
agent_name
. c. LiveKit assigns the job to the running agent server and the agent joins the room. 3) If you prefer token-based dispatch on join • Ensure the JWT you issue includes
room_config.agents
with a RoomAgentDispatch that has
agent_name="cloud-english-teacher"
(and
metadata
as a JSON string). • Also ensure the agent server does NOT have
agent_name
set in a way that disables automatic dispatch (or use a nameless agent for automatic dispatch). 4) Immediate checks to run now • Decode the token you generated and paste the payload (redact secrets). Confirm presence/absence of
room_config.agents
. • Check agent server logs for incoming dispatch attempts or errors around the time you press Start. • Confirm exact agent name string (copy/paste) — it must match exactly. If you want, tell me which method you prefer (explicit API dispatch on Start, or token-based auto-dispatch). I can then: • Provide the exact CreateAgentDispatch API request example (JS/Node or Python) to call from your backend, or • Show the corrected token-generation snippet that embeds
room_config.agents
.
m
what method do you recomened ?
t
I recommend explicit API dispatch (call CreateAgentDispatch from your backend when the user clicks Start). Why: • It maps directly to a user action — you control exactly when the agent is assigned and can pass session-specific metadata. • It works even when your agent was created with
agent_name
(that setting disables automatic dispatch). • Easier to debug and observe in agent/server logs vs relying on token timing. What to do next (high level) 1. User clicks Start → frontend calls your backend endpoint. 2. Backend calls LiveKit CreateAgentDispatch for the room with
agent_name="cloud-english-teacher"
and any
metadata
. 3. LiveKit assigns the job and the agent server joins the room and begins speaking. Would you like the exact CreateAgentDispatch request example in Node or Python and the minimal backend endpoint code?
m
python please
t
Below is a concise Python example showing a minimal backend endpoint that calls LiveKit’s CreateAgentDispatch API when the user clicks Start. This assumes you run it in a serverless function or small web server that receives the room name and any metadata from the frontend. What this does: • Accepts POST { room_name, metadata } from your frontend when Start is pressed. • Calls the LiveKit CreateAgentDispatch REST API to dispatch agent_name "cloud-english-teacher" to that room. • Returns API response to the frontend. Required setup • LIVEKIT_API_KEY and LIVEKIT_API_SECRET for your LiveKit Cloud project (kept secret on backend). • The agent name: "cloud-english-teacher". • The LiveKit REST base URL: use your project subdomain host (e.g., turbo-ms4yz8cm.livekit.cloud). The CreateAgentDispatch endpoint is: POST https://{project_subdomain}.livekit.cloud/v1/agents/dispatch Example (FastAPI + requests):
Copy code
from fastapi import FastAPI, Request, HTTPException
import os
import json
import time
import hmac
import hashlib
import base64
import requests

app = FastAPI()

API_KEY = os.environ["LIVEKIT_API_KEY"]
API_SECRET = os.environ["LIVEKIT_API_SECRET"]
PROJECT_HOST = os.environ["LIVEKIT_PROJECT_HOST"]  # e.g. turbo-ms4yz8cm.livekit.cloud
AGENT_NAME = "cloud-english-teacher"

def make_auth_header(api_key: str, api_secret: str):
    # LiveKit REST uses HMAC-based Authorization: Authorization: LK <apiKey>:<signature>
    ts = str(int(time.time()))
    msg = f"{api_key}:{ts}".encode()
    sig = hmac.new(api_secret.encode(), msg, hashlib.sha256).hexdigest()
    return {"Authorization": f"LK {api_key}:{sig}", "LiveKit-Timestamp": ts, "Content-Type": "application/json"}

@app.post("/dispatch")
async def dispatch(request: Request):
    body = await request.json()
    room_name = body.get("room_name")
    metadata = body.get("metadata")  # dict or string

    if not room_name:
        raise HTTPException(status_code=400, detail="room_name required")

    if isinstance(metadata, dict):
        metadata = json.dumps(metadata)

    url = f"https://{PROJECT_HOST}/v1/agents/dispatch"
    payload = {
        "room": room_name,
        "agent_name": AGENT_NAME,
        "metadata": metadata or ""
    }

    headers = make_auth_header(API_KEY, API_SECRET)
    resp = requests.post(url, headers=headers, json=payload, timeout=10)

    if resp.status_code != 200:
        raise HTTPException(status_code=resp.status_code, detail=resp.text)

    return resp.json()
Notes and tips • Use the project host for your LiveKit Cloud project (the same subdomain used by your frontend WebSocket URL). • Ensure the agent server is running and registered under the exact name
cloud-english-teacher
. • Check agent logs after dispatch — they show assignment and join events. • If your environment (Vercel serverless) restricts outgoing requests, ensure outbound HTTPS to LiveKit is allowed. • If your LiveKit deployment requires different auth, adjust the auth header accordingly. If you’d like, I can produce a version using the official LiveKit Python SDK or show how to call this from your frontend. Would you like the same example using the LiveKit Python SDK (if available) or a minimal curl example to test quickly?
m
we are doing this now ; Ah! This is a different approach - instead of using room configuration in the token (which we're doing now), this manually calls the LiveKit CreateAgentDispatch API after the room is created. Current approach (what we have now): • Token contains roomConfig with agent dispatch • LiveKit Cloud automatically dispatches agent when room is created • ✅ Simpler, less code
t
Using roomConfig in the token for automatic dispatch is a valid, simpler approach — and it can work fine. Quick checklist to ensure it actually dispatches your running agent "cloud-english-teacher": • Token must include
room_config.agents
with a RoomAgentDispatch that has
agent_name: "cloud-english-teacher"
and optional
metadata
(JSON string). • Ensure you import and build `RoomConfiguration`/`RoomAgentDispatch` from
livekit.api
(not
livekit.protocol
). • The agent name in the token must exactly match the agent server’s registered name (case-sensitive). • The agent server must be running and registered with LiveKit Cloud (check agent logs for incoming dispatch jobs). • If your agent was created with an
agent_name
that disables automatic dispatch, automatic dispatch will not occur — in that case use explicit CreateAgentDispatch instead. • Decode your issued JWT and confirm
room_config.agents
is present and correct. Also check LiveKit and agent server logs at the time the room is created. If you want, paste the decoded token payload (redact secrets) or the agent server log lines around the room creation and I’ll spot any mismatch or missing field.
m
we are hosting on livekit cloud no server
t
Thanks — since you’re hosting only on LiveKit Cloud (no separate backend), here’s what matters and the two clear options to make the agent join reliably. Why token-based auto-dispatch can fail on Cloud-only setups • Auto-dispatch requires an available agent server registered to your project with the exact
agent_name
. If the agent was created with
agent_name
that disables automatic dispatch, it will not auto-join. • The JWT you issue must contain
room_config.agents
(RoomAgentDispatch) — if the token lacks it, no dispatch is triggered. • If your frontend directly creates the token or room without a backend step, you may be issuing tokens that don’t include the room config or are missing required grants. Two options (choose one) 1) Continue token-based automatic dispatch (keep current simpler approach) • Ensure your JWT includes
room_config.agents
with
agent_name: "cloud-english-teacher"
and
metadata
as a JSON string. • Import/build the room config from
livekit.api
in your token generation code: ◦
from livekit.api import RoomConfiguration, RoomAgentDispatch
• The agent server must be running and registered under exactly
cloud-english-teacher
. • If the agent was created with
agent_name
that disables auto-dispatch, recreate or update it so automatic dispatch is allowed. • Verify by decoding the token and confirming
room_config.agents
is present; check agent logs for incoming dispatch. 2) Recommended — explicit dispatch on Start (more reliable, minimal backend) • When user presses Start, call LiveKit’s CreateAgentDispatch from a small serverless endpoint (Vercel function, Cloud Run, etc.). This is reliable even if agent has
agent_name
set. • Minimal flow: a. Frontend: POST /dispatch with room_name and metadata. b. Backend: call POST https://{project_subdomain}.livekit.cloud/v1/agents/dispatch with
room
,
agent_name
,
metadata
. c. LiveKit assigns agent and agent server joins room. • Use HMAC auth header pattern shown earlier or the LiveKit SDK if available in your environment. Quick next steps I can provide right now • If you want to keep token-based dispatch: paste the decoded JWT payload (redact secrets) and I’ll confirm
room_config.agents
is correct. • If you prefer explicit dispatch: I can give a compact Vercel serverless function example (Python or Node) to call CreateAgentDispatch with the exact headers/payload. Which do you want to do now — verify the token or add a tiny dispatch endpoint?
m
an ides : ❌ Agent dispatch failed: {"error": "Invalid JSON response: OK", "type": "Exception", "traceback": "Traceback (most recent call last):\n File \"/var/task/api/dispatch-agent.py\", line 61, in do_POST\n response_data = json.loads(response_body)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/var/lang/lib/python3.12/json/__init__.py\", line 346, in loads\n return _default_decoder.decode(s)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/var/lang/lib/python3.12/json/decoder.py\", line 338, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/var/lang/lib/python3.12/json/decoder.py\", line 356, in raw_decode\n raise JSONDecodeError(\"Expecting value\", s, err.value) from None\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/var/task/api/dispatch-agent.py\", line 67, in do_POST\n raise Exception(f\"Invalid JSON response: {response_body[:100]}\")\nException: Invalid JSON response: OK\n"} disconnect from room 1. _{room: 'lesson-2e80a07d', roomID: 'RM_GZ8BQfDatwJp', participant: 'student-5904ce39', pID: 'PA_2atXNk8jw3CC'}_ 2. pID 3. : a. "PA_2atXNk8jw3CC" 4. participant 5. : a. "student-5904ce39" 6. room 7. : a. "lesson-2e80a07d" 8. roomID 9. : a. "RM_GZ8BQfDatwJp" 10. [[Prototype]] 11. : a. Object
t
You're getting "Invalid JSON response: OK" because your function attempted to parse the HTTP response body as JSON but the endpoint returned a plain "OK" string (not JSON). That means the request to the dispatch endpoint didn't return the expected JSON payload. Here's how to fix and diagnose it. What to check now • Endpoint URL: confirm you're POSTing to https://{project_subdomain}.livekit.cloud/v1/agents/dispatch • HTTP status: log the response status code (200 vs 204). A 204 or plain 200 with text "OK" means no JSON body to parse. • Headers: include Content-Type: application/json and Accept: application/json. • Auth: ensure your HMAC auth header and LiveKit-Timestamp are correct (wrong auth can produce non-JSON responses). • Payload: ensure JSON body has
room
,
agent_name
, and
metadata
(metadata can be empty string). • Agent server: verify agent is running and able to accept dispatches. Quick code fixes (Python) • Use resp.status_code and resp.text to inspect non-JSON responses before json.loads. • Prefer resp.json() inside try/except; handle JSONDecodeError by returning resp.text. Minimal corrected pattern: 1) Inspect status and body
Copy code
resp = requests.post(url, headers=headers, json=payload, timeout=10)
print("status:", resp.status_code)
print("body:", resp.text[:200])
if resp.status_code != 200:
    raise Exception(f"Dispatch failed: {resp.status_code} {resp.text}")
try:
    data = resp.json()
except ValueError:
    raise Exception(f"Invalid JSON response: {resp.text!r}")
2) Ensure headers include Accept and Content-Type
Copy code
headers = {
  "Authorization": f"LK {API_KEY}:{signature}",
  "LiveKit-Timestamp": ts,
  "Content-Type": "application/json",
  "Accept": "application/json",
}
If you run that and still get "OK", paste: • the printed status code and resp.text • your full dispatch URL and headers (redact secrets) • the exact payload body I’ll review those and give the exact fix. Which of those outputs can you share?
m
Perfect! The dispatch is succeeding (you see "Agent dispatched successfully" with HTTP 200 and "OK" response). The problem is the agent isn't actually joining the room. Looking at your logs, I don't see any "👤 Participant connected" event, which means the agent server isn't picking up the dispatch or joining the room. The issue is likely: The JWT token we're using for the dispatch API might not have the right permissions, OR the agent server isn't listening for dispatches properly. Let me ask your LiveKit expert this: **"The dispatch API returns 200 OK, which means the dispatch succeeded. However, the agent doesn't join the room. Here's what we're doing: 1. Using livekit.api.AccessToken(API_KEY, API_SECRET).to_jwt() for auth 2. POSTing to https://turbo-ms4yz8cm.livekit.cloud/v1/agents/dispatch 3. Payload: {"room": "lesson-xxx", "agent_name": "cloud-english-teacher", "metadata": "{\"persona\": \"Taxi Driver\"}"} 4. Getting 200 OK response The agent cloud-english-teacher is deployed and shows as RUNNING in LiveKit Cloud, but it never joins rooms. Questions: 1. Does the AccessToken for dispatch API need specific grants/permissions? 2. Should we check agent logs to see if it's receiving dispatch requests? 3. Is there a different auth method we should use for the dispatch API? 4. Could the agent need to be configured differently to accept dispatches?"** Please share their response and I'll implement the fix!
t
Great details — here are direct answers and the exact steps to fix this. Short answers to your four questions 1. Yes — the token used to call the dispatch API must include admin privileges. Create a JWT with a VideoGrant that includes
room_admin=True
(and
room_join=True
for the target room). 2. Yes — check the agent logs immediately after dispatch; they show if the agent received the job and why it may have declined or failed to join. Use
lk agent logs --project "<project-id>" --id "<agent-id>"
. 3. The auth method (JWT via Authorization header) is correct, but the JWT must carry the admin grant. The dispatch endpoint won’t successfully cause the agent to join if the token lacks
room_admin
. 4. Yes — agent config matters. If the agent was registered with an
agent_name
that disables automatic dispatch, explicit dispatch is required and the
agent_name
used in the API call must exactly match the registered name. Exact fix — generate a proper dispatch token (Python)
Copy code
from livekit import api
from livekit.apis.rtc import VideoGrant

token = (
    api.AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET)
    .with_grants(VideoGrant(room="lesson-xxx", room_join=True, room_admin=True))
    .to_jwt()
)
# Use this JWT as Authorization: Bearer <token> in your POST to /v1/agents/dispatch
What to do now (step-by-step) 1. Regenerate a dispatch token using the snippet above (replace room). 2. Call POST https://{project_subdomain}.livekit.cloud/v1/agents/dispatch with JSON: { "room": "lesson-xxx", "agent_name": "cloud-english-teacher", "metadata": "{\"persona\":\"Taxi Driver\"}" } and Authorization: Bearer <token>. Include Content-Type and Accept application/json headers. 1. Immediately tail agent logs: lk agent logs --project "<project-id>" --id "CA_e7hLTus66nKZ" Look for job assignment or join attempts and any error lines. 1. If no log lines appear, verify the agent is RUNNING in Cloud and the registered name exactly equals "cloud-english-teacher". If agent logs show an error, paste the relevant lines. If you want, paste: • The dispatch response status and body (you said 200/OK — include headers if possible) • The agent log lines after dispatch (redact secrets) I’ll read those and tell you the exact next action. Sources: Agent dispatch | LiveKit docs | Authentication | LiveKit docs | sip | livekit/livekit_composite | DeepWiki | Log collection | LiveKit Docs | SIP APIs | LiveKit docs
m
how do we fi tghis error : ❌ Agent dispatch failed: {"error": "identity and room must be set when joining a room", "type": "ValueError", "traceback": "Traceback (most recent call last):\n File \"/var/task/api/dispatch-agent.py\", line 43, in do_POST\n jwt_token = access_token.to_jwt()\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/var/task/_vendor/livekit/api/access_token.py\", line 197, in to_jwt\n raise ValueError(\"identity and room must be set when joining a room\")\nValueError: identity and room must be set when joining a room\n"}
t
That error means the AccessToken you’re building is missing the required
identity
and
room
fields. When generating a token used to join a room (or to dispatch an agent that will join a room), you must set both. Fix — include identity and room when creating the token. Example Python:
Copy code
from livekit import api
from livekit.apis.rtc import VideoGrant

token = (
    api.AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET)
    .with_identity("dispatch-service")              # required
    .with_grants(VideoGrant(room="lesson-xxx", room_join=True, room_admin=True))
    .to_jwt()
)
# Use Authorization: Bearer <token> for POST /v1/agents/dispatch
Checklist • Set
.with_identity(...)
to a unique string for the service making the dispatch. • Set
VideoGrant(room="<room_name>", room_join=True, room_admin=True)
. • Use that JWT in the Authorization header when calling /v1/agents/dispatch. • Tail agent logs after dispatch to confirm it receives the job. If you want, paste the snippet you’re using to generate the token (redact keys) and I’ll point out the exact line to change.
m
1. sgent not talking? API Response: _{token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiU…1MDN9.atzxK7LljAVCtrfUinbwU9IRwtazBvuvsLGwKfVs8S8', room_name: 'lesson-27305393', url: 'wss://turbo-ms4yz8cm.livekit.cloud', persona: 'English Teacher', agent_status: 'enabled'}_ 🔗 Connecting to: 🎫 Token (first 50 chars): eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiU... ✅ Connected to room ✅ Room.connect() completed 🚀 Dispatching agent to room... ✅ Agent dispatched: 1. {suc_cess: true, room_name: 'lesson-27305393', agent_name: 'cloud-english-teacher', persona: 'English Teacher', dispatch_response: {…}}_ 2. agen*t_name* : 1. "cloud-english-teacher" 1. dis*patch_response* : 1. {status: 'success', message: 'Agent dispatched successfully', http_status: 200, response: 'OK'} 1. pe*rsona* 2. : 3. "English Teacher" 1. r*oom_name* 2. : 3. "lesson-27305393" a. 4. success 5. : a. true 6. [[Prototype]] 7. : a. Object
no agent
t
Good — you’ve confirmed dispatch succeeds but the agent never speaks. That means the agent either never started an active session after joining, or it started but wasn’t instructed to generate audio. Here’s a concise checklist and the minimal code/action items to get it talking. Immediate checklist • Confirm the agent actually joined the room (tail agent logs after dispatch). Look for join/session start logs — if none appear, the agent never received/accepted the job. • If the agent joined, confirm agent code calls
session.start(...)
and then explicitly calls
session.generate_reply(...)
or
session.say(...)
. Joining alone does not produce speech. • Check agent logs for errors from LLM/TTS calls (API failures, auth errors, or timeouts). • Ensure the agent is registered with the exact name
cloud-english-teacher
and running in LiveKit Cloud. Minimal agent fix (Python pseudocode)
Copy code
async def my_agent_handler(ctx: JobContext):
    session = AgentSession(
        stt="assemblyai/universal-streaming:en",
        llm="openai/gpt-4.1-mini",
        tts="cartesia/sonic-3:...token..."
    )

    await session.start(room=ctx.room, agent=Assistant())
    # trigger the first utterance explicitly:
    await session.generate_reply(instructions="Greet the user warmly and introduce the lesson.")
What to do now 1. Tail logs immediately after dispatch: lk agent logs --project "<project-id>" --id "CA_e7hLTus66nKZ" • If no join/start lines appear, the agent didn’t receive the dispatch. • If join/start appears but no generate/say calls or errors follow, the agent code isn’t initiating speech or LLM/TTS failed. 1. If you want, paste the agent log lines shown after dispatch (redact secrets). I’ll pinpoint whether it’s a join problem, a missing generate/say call, or an LLM/TTS error and give the exact code or config change. Sources: Agents (Node.js) | livekit/livekit_composite | DeepWiki | Agents v0.x migration guide - Python | LiveKit docs | Agents telephony integration | LiveKit docs | Voice AI quickstart | LiveKit docs
Thanks — you’ve confirmed dispatch succeeds but the agent still isn’t speaking. Let’s pinpoint whether the agent actually joined the room or joined but never generated speech. Short actionable steps (run in this order) 1) Tail agent logs immediately after you dispatch • Command: lk agent logs --project "<your-project-id>" --id "CA_e7hLTus66nKZ" • What to look for: ◦ Join/session start lines (e.g., “Agent session started”, “Participant connected”, or similar). ◦ Any errors from
session.start()
,
generate_reply()
or TTS/LLM calls. • Paste the relevant log lines here (redact secrets). If no join/start lines appear, the agent never received/accepted the job. 2) If logs show the agent joined the room • Check whether agent code explicitly triggers speech after start. The agent will not speak automatically; you must call
session.generate_reply()
or
session.say()
after
session.start()
. • Minimal pattern (ensure equivalent exists in your agent code):
Copy code
await session.start(room=ctx.room, agent=Assistant())
  await session.generate_reply(instructions="Greet the user warmly and introduce the lesson.")
• If this call is missing, add it, redeploy, and test again. 3) If logs show no join/start or show errors on join • Confirm the dispatch token had correct grants: token used for dispatch must include an identity and VideoGrant with
room_join=True
and
room_admin=True
. Example:
Copy code
token = (
    api.AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET)
    .with_identity("dispatch-service")
    .with_grants(VideoGrant(room="lesson-27305393", room_join=True, room_admin=True))
    .to_jwt()
  )
• Verify the
agent_name
in your dispatch call exactly matches the agent’s registered name (
cloud-english-teacher
). • Look for LLM/TTS errors in logs (auth, rate limits, or timeouts) — these prevent speech even if joined. 4) Quick diagnostic you can run now • Dispatch, then immediately run the logs command and paste 20–50 lines of output here. • If you prefer, paste the decoded JWT payload used for dispatch (redact secrets) so I can confirm
room_config
/ grants. Tell me which log output you can share (agent logs or decoded token) and I’ll point to the exact line to change. Sources: Deploying to production | LiveKit Docs | Agent dispatch | LiveKit docs | Agents telephony integration | LiveKit docs
m
The agent code looks correct. The issue is likely that the agent isn't receiving the dispatch at all. Given that we've been troubleshooting for a while and the dispatch setup is complex, let me simplify by going back to the token-based approach but with the correct configuration this time. Looking at the conversation history, we know: 1. ✅ Agent is deployed and running 2. ✅ Dispatch API returns 200 OK 3. ❌ Agent never joins the room Since you have direct access to the LiveKit expert, please ask them: **"Can you check the agent logs for CA_e7hLTus66nKZ to see if it's receiving dispatch requests? The dispatch API returns 200 OK but the agent never joins rooms. Our dispatch call: • URL: https://turbo-ms4yz8cm.livekit.cloud/v1/agents/dispatch • Body: {"room": "lesson-xxx", "agent_name": "cloud-english-teacher", "metadata": "{\"persona\": \"Taxi Driver\"}"} • Auth: Bearer JWT with identity="dispatch-service", room="lesson-xxx", room_join=True, room_admin=True • Response: 200 OK What do the agent logs show?"** Their response will tell us exactly what's failing!
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
m
agent did not join room ?