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:
| Subject | Meaning |
|---|---|
stream-video/started | Video generation started |
stream-video/done | Video generation completed |
stream-video/error | Video generation failed |
Chat events — fired when chat messages are added to history or when the user's audio is transcribed:
| Subject | Meaning |
|---|---|
chat/partial | Partial LLM response (streaming, chat only) |
chat/answer | Assistant message added to chat history |
chat/audio-transcribed | User audio transcription (when using microphone) |
Tool events — fired when the agent invokes a tool:
| Subject | Meaning |
|---|---|
tool-call/started | Tool call started |
tool-call/done | Tool call completed |
tool-call/error | Tool 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;
}
});Updated 1 day ago
What’s Next
