Listen for Agent Events

The agent sends responses back to your app as data events on the LiveKit data channel. Listen on RoomEvent.DataReceived and route by the event's subject field.

Note: Attach the listener before calling room.connect() so you don't miss events that fire during connection.

Event envelope

All agent events arrive as JSON with at least a subject field:

{
  "subject": "event_type",
  "content": "response text (chat events)",
  "description": "error details (error events)"
}

Event catalog

Video events — fired for every video sequence the agent produces:

SubjectMeaning
stream-video/startedVideo generation started
stream-video/doneVideo generation completed
stream-video/errorVideo generation failed

Chat events — fired when chat messages are added to history or when the user's audio is transcribed:

SubjectMeaning
chat/partialPartial LLM response (streaming, chat only)
chat/answerAssistant message added to chat history
chat/audio-transcribedUser audio transcription (when using microphone)

Tool events — fired when the agent invokes a tool:

SubjectMeaning
tool-call/startedTool call started
tool-call/doneTool call completed
tool-call/errorTool call failed

Listening for events

   room.on(RoomEvent.DataReceived, (payload, participant, kind, topic) => {
     const data = JSON.parse(new TextDecoder().decode(payload));

     switch (data.subject) {
       case "stream-video/started":
         console.log("Video generation started");
         break;
       case "stream-video/done":
         console.log("Video complete");
         break;
       case "chat/partial":
         console.log("Partial:", data.content);
         break;
       case "chat/answer":
         console.log("Answer:", data.content);
         break;
     }
   });