Skip to content

Agent dispatch created via RoomServiceClient.createRoom missing room field #4357

@marcellonascif

Description

@marcellonascif

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

  1. 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" }) });
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions