famous-finland-27043
11/01/2025, 12:00 PMtall-airline-16756
11/01/2025, 12:01 PMtall-airline-16756
11/01/2025, 12:02 PMParticipantKind.AGENT, so you can easily distinguish them from regular participants in your application logic.
For instance, in the on_participant_connected method, you can simply skip processing agent participants like this:
def on_participant_connected(self, participant: rtc.RemoteParticipant):
# Skip if the participant is an agent
if participant.kind == rtc.ParticipantKind.AGENT:
logger.info(f"Ignoring agent participant: {participant.identity}")
return
if participant.identity in self._sessions:
return
logger.info(f"starting session for {participant.identity}")
task = asyncio.create_task(self._start_session(participant))
self._tasks.add(task)
# ... rest of the method
Also, a helpful tip is to use token-based permissions to limit what agents can do. For example, setting canPublish: false and canSubscribe: true in their tokens allows agents to listen to audio without being able to publish. This adds an extra layer of control.
If you'd like, I’m here to help you implement these changes or answer any questions you might have. Just let me know!
Sources: src/lib/controller.ts | examples/other/transcription/multi-user-transcriber.py | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Parti... | agent/game_host.py | Node.js Agents Architecture | livekit/livekit_composite | DeepWikifamous-finland-27043
11/01/2025, 12:11 PMtall-airline-16756
11/01/2025, 12:13 PMpermissions parameter within the WorkerOptions when you initialize the agent. This lets you control capabilities like canPublish, canSubscribe, canPublishData, and canUpdateMetadata to suit your needs.
Here’s a friendly example in Python that shows how to define custom permissions:
from livekit.agents import WorkerPermissions, WorkerOptions, cli
permissions = WorkerPermissions(
can_publish=True, # Allow publishing audio/video
can_subscribe=True, # Allow subscribing to other participants
can_publish_data=False, # Disallow sending data messages
can_update_metadata=True # Allow updating own metadata
)
cli.run_app(WorkerOptions(
entrypoint_fnc=entrypoint, # Your entrypoint function
permissions=permissions
))
Within your entrypoint function, these permissions will be respected. So, for instance, if canPublish is set to False, any attempts to publish tracks won’t go through.
If you’d like, I’m here to walk you through implementing this in your specific setup or answer any questions you might have!
Sources: Worker options | LiveKit Docs | Job lifecycle | LiveKit Docs | agent/main.pyfamous-finland-27043
11/01/2025, 12:16 PMtall-airline-16756
11/01/2025, 12:16 PMWorkerOptions class and, once set, they stay the same throughout the worker’s lifecycle. This means they can’t be changed later within the agent’s entrypoint code, and these permissions apply to all agents created by that worker.
If you’re looking to adjust permissions dynamically during a session, the best way is to handle that outside the agent’s entrypoint—like through an external service or an API call using a server SDK. I’m here to help if you want some guidance on how to set this up, just let me know!
Sources: Worker options | LiveKit Docs | Authentication | LiveKit Docsfamous-finland-27043
11/01/2025, 12:19 PMtall-airline-16756
11/01/2025, 12:19 PMVideoGrant fields like canPublish, canSubscribe, and canPublishData. This approach gives you more precise control.
For example, when you're generating the agent's token, it might look something like this:
grant := &auth.VideoGrant{
RoomJoin: true,
Agent: true,
Room: roomName,
CanPublish: true, // allows publishing tracks
CanSubscribe: true, // allows subscribing to others
CanPublishData: true, // allows sending data messages
Hidden: true, // hides agent from participant list
CanUpdateOwnMetadata: true // allows updating its own metadata
}
at := auth.NewAccessToken(apiKey, secret).
SetVideoGrant(grant).
SetIdentity("agent-123").
SetKind("agent").
ToJWT()
Also, just a quick note: the RoomConfiguration.agents field in the participant's token is used only to dispatch the agent to join the room—it doesn’t actually control the permissions.
If you have any questions or need a hand with token generation or setting up agent permissions, please don’t hesitate to ask. I’m here to help!
Sources: Authentication | LiveKit Docs | app/api/connection-details/route.ts | examples/agent_dispatch.py | client/web/src/app/api/connection-details/route.ts | protobufs/livekit_token_source.protofamous-finland-27043
11/02/2025, 5:09 AMtall-airline-16756
11/02/2025, 5:10 AMfamous-finland-27043
11/02/2025, 5:10 AMtall-airline-16756
11/02/2025, 5:10 AMconst allTracks = useTracks(
[Track.Source.Camera, Track.Source.ScreenShare, Track.Source.Unknown],
{ onlySubscribed: true }
);
const filteredTracks = allTracks.filter(
(tr) => tr.participant.kind !== ParticipantKind.AGENT
);
<GridLayout tracks={filteredTracks}>
<ParticipantTile />
</GridLayout>
In this example, tracks from participants with the kind ParticipantKind.AGENT are removed from the grid layout, so they won’t be shown.
If you’d like, I’m here to help you step-by-step with implementing this or to answer any other questions you might have!