When calling createRoom method from RoomServiceClient using options parameter with agents: [RoomAgentDispatch], the server creates an internal AgentDispatch for each agent, but the resulting dispatch record does not have the roomName field populated.
In the other hand, when creating a dispatch via the dedicated AgentDispatchClient using createDispatch with roomName specified, the returned dispatch correctly includes roomName.
This causes consumers of the dispatch (agents) not to be able to retrieve room context (e.g. room metadata) from the dispatch itself (when it is created via createRoom).
Server
Node.js version: v24.13.0
livekit-server-sdk version used: 2.15.0
@livekit/protocol used is the SDK-generated protos in package
- Reproduction tested with
lk CLI where output shown above
To Reproduce
- Use the
livekit-server-sdk to call createRoom with agents set:
// src/index.ts (example)
import { RoomServiceClient, AgentDispatchClient, RoomAgentDispatch } from "livekit-server-sdk";
const rs = new RoomServiceClient(LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
const ds = new AgentDispatchClient(LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET);
await rs.createRoom({
name: "test-room",
metadata: JSON.stringify({ description: "Test room created via server SDK" }),
emptyTimeout: 300,
maxParticipants: 10,
agents: [
new RoomAgentDispatch({
agentName: "test-agent",
metadata: JSON.stringify({ description: "Test agent for room" }),
}),
],
});
// separately, explicit dispatch:
await ds.createDispatch("test-room", "test-agent", { metadata: JSON.stringify({ description: "Test agent for dispatch" }) });
- Inspect results using
lk CLI (or AgentDispatch API):
lk room list -j
lk dispatch list test-room
Expected behavior
When CreateRoom is called with agents, the agent dispatches created explicitly for that room should include the room field set to the room name (e.g. test-room) so that the dispatchs are fully contexted and agents can query room metadata based on the dispatch.
Observed
lk room list -j shows the created room test-room with metadata.
lk dispatch list test-room shows two dispatchs: one created via createDispatch with room: "test-room", and one created via createRoom (agents) where Room column is empty.
Example output captured during reproduction:
Using default project [triagen]
{
"rooms": [
{
"sid": "RM_g4XtU46n2tQB",
"name": "test-room",
"metadata": "{\"description\":\"Test room created via server SDK\"}",
"version": { "unixMicro": "..." }
}
]
}
---
Using default project [triagen]
┌─────────────────┬────────────┬─────────────┬───────────────────────────────────────────┐
│ DispatchID │ Room │ AgentName │ Metadata │
├─────────────────┼────────────┼─────────────┼───────────────────────────────────────────┤
│ AD_qqwDPdzLzbxD │ test-room │ test-agent │ {"description":"Test agent for dispatch"} │
│ AD_zvNQmyWiVNQB │ │ test-agent │ {"description":"Test agent for room"} │
└─────────────────┴────────────┴─────────────┴───────────────────────────────────────────┘
Please let me know if you want more information or if you'd like me to open a PR with a fix suggestion.
When calling
createRoommethod fromRoomServiceClientusingoptionsparameter withagents: [RoomAgentDispatch], the server creates an internal AgentDispatch for each agent, but the resulting dispatch record does not have theroomNamefield populated.In the other hand, when creating a dispatch via the dedicated
AgentDispatchClientusingcreateDispatchwithroomNamespecified, the returned dispatch correctly includesroomName.This causes consumers of the dispatch (agents) not to be able to retrieve room context (e.g. room metadata) from the dispatch itself (when it is created via
createRoom).Server
Node.jsversion: v24.13.0livekit-server-sdkversion used: 2.15.0@livekit/protocolused is the SDK-generated protos in packagelkCLI where output shown aboveTo Reproduce
livekit-server-sdkto callcreateRoomwithagentsset:lkCLI (or AgentDispatch API):Expected behavior
When
CreateRoomis called withagents, the agent dispatches created explicitly for that room should include theroomfield set to the room name (e.g.test-room) so that the dispatchs are fully contexted and agents can query room metadata based on the dispatch.Observed
lk room list -jshows the created roomtest-roomwith metadata.lk dispatch list test-roomshows two dispatchs: one created viacreateDispatchwithroom: "test-room", and one created viacreateRoom(agents) whereRoomcolumn is empty.Example output captured during reproduction:
Please let me know if you want more information or if you'd like me to open a PR with a fix suggestion.