Skip to content

Server RoomServiceClient.sendData no longer received by agent after upgrading to @livekit/[email protected] and @livekit/[email protected] #587

@gabriel-abramovich

Description

@gabriel-abramovich

Select which package(s) are affected

@livekit/rtc-node

Describe the bug

Summary

After upgrading to @livekit/rtc-node 0.13.22 and @livekit/agents 1.0.31, server-side data messages sent with RoomServiceClient.sendData are no longer received by the agent, even though the code, topic, and room wiring have not changed.

The same code works as expected with @livekit/agents 1.0.22 and @livekit/rtc-node 0.13.20.

Environment

  • @livekit/rtc-node version: 0.13.22
  • @livekit/agents version: 1.0.31
  • Previous working versions:
    • @livekit/rtc-node 0.13.20
    • @livekit/agents 1.0.22

Current behavior

The backend sends a reliable data packet with a specific topic from the server using RoomServiceClient.sendData, but the agent that is joined to the room no longer receives this message after the upgrade.

Previously working server-side code:

const roomService = new RoomServiceClient(livekitUrl, livekitApiKey, livekitApiSecret);
const textId = randomUUID();
const message = {
  action: 'add_text',
  text_id: textId,
  text: 'Good job!',
};

await roomService.sendData(
  args.input.roomName,
  new TextEncoder().encode(JSON.stringify(message)),
  DataPacket_Kind.RELIABLE,
  { topic: 'server-commands' },
);

With the previous versions (@livekit/agents 1.0.22 / @livekit/rtc-node 0.13.20), the agent receives this data message as expected.

With the new versions (@livekit/agents 1.0.31 / @livekit/rtc-node 0.13.22), the agent no longer receives this data packet, even though:

  • The code shown above is unchanged
  • The topic ('server-commands') is unchanged
  • The agent code that listens for data messages is unchanged

Expected behavior

RoomServiceClient.sendData should continue to deliver reliable data packets with a topic to all participants in the room, including the agent, as it did in @livekit/agents 1.0.22 / @livekit/rtc-node 0.13.20.

The agent should receive the JSON payload and be able to handle the server-commands topic as before.

Reproduction

  1. Set up a LiveKit room with an agent using @livekit/agents 1.0.31 and @livekit/rtc-node 0.13.22
  2. Ensure the agent is listening for data messages on the topic 'server-commands'
  3. From a Node.js backend, use RoomServiceClient.sendData() to send a data packet:
    const roomService = new RoomServiceClient(livekitUrl, livekitApiKey, livekitApiSecret);
    await roomService.sendData(
      roomName,
      new TextEncoder().encode(JSON.stringify({ action: 'add_text', text: 'Test' })),
      DataPacket_Kind.RELIABLE,
      { topic: 'server-commands' },
    );
  4. Observe that the agent does NOT receive the data message
  5. Downgrade to @livekit/agents 1.0.22 and @livekit/rtc-node 0.13.20
  6. Repeat steps 3-4
  7. Observe that with the older versions, the agent DOES receive the data message

Logs

System Info

- OS: Node.js environment (server-side)
- @livekit/rtc-node: 0.13.22 (broken) / 0.13.20 (working)
- @livekit/agents: 1.0.31 (broken) / 1.0.22 (working)
- Node.js: v22.19.0

LiveKit server version

LiveKit cloud

Severity

blocking an upgrade

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions