little-king-41579
02/18/2026, 5:29 AMtall-airline-16756
02/18/2026, 5:29 AMtall-airline-16756
02/18/2026, 5:29 AMclaim_admin joins a room. Below are concise, actionable examples and guidance for both Python and Node.js using the agent session's event hook and set_audio_enabled to disable the agent's audio output.
What I'll cover:
• Listen for the participant-connected event
• Check the participant identity for claim_admin
• Mute the agent with session.output.set_audio_enabled(False) (or false in JS)
Python example
@server.rtc_session()
async def entrypoint(ctx: JobContext):
session = AgentSession(
# your model/STT/TTS settings
)
await session.start(agent=MyAgent(), room=ctx.room)
def on_participant_connected(participant: rtc.RemoteParticipant):
if participant.identity == "claim_admin":
session.output.set_audio_enabled(False) # mute agent
ctx.room.on("participant_connected", on_participant_connected)
await ctx.connect()
Node.js / TypeScript example
import { voice } from '@livekit/agents';
export default defineAgent({
entry: async (ctx: JobContext) => {
const session = new voice.AgentSession({
// your model/STT/TTS settings
});
await session.start({ agent: new MyAgent(), room: ctx.room });
ctx.room.on('participantConnected', (participant) => {
if (participant.identity === 'claim_admin') {
session.output.setAudioEnabled(false); // mute agent
}
});
await ctx.connect();
}
});
Notes and optional behavior
• To unmute later, call session.output.set_audio_enabled(True) in Python or session.output.setAudioEnabled(true) in JS.
• If you need to mute only specific agent voices or conditionally (e.g., only during certain times), you can add more checks inside the handler before calling set_audio_enabled.
• If your environment emits a slightly different event name, confirm the room event for participant connection and adapt the handler name accordingly.
If you want, tell me which language/environment you’re using and whether you want the agent to automatically unmute later (and when), and I’ll provide the exact code snippet to match that behavior.
Sources: Text and transcriptions | LiveKit Documentation