How can i change the name of the agent participant...
# ask-ai
f
How can i change the name of the agent participant that will be joining a livekit room. I have used the
await ctx.agent.set_name("Agent name")
But when two agents are joining the same room, they are being named "simulated_agent_y7236" by livekit itself. I dont have this issue when only a single agent is entering the room. Using v1.2.8 of agent and for front end i am using the meet git example from livekit itself
t
Thanks for reaching out, Alexander. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! Just to better assist you, could you please let me know if you're setting the agent names dynamically during runtime or right at the start? Also, are you making sure that each agent has unique identifiers or metadata when they join the room? I'm here to help you through this! Sources: Anam virtual avatar integration guide | LiveKit Docs | Agent dispatch | LiveKit Docs | examples/agent_dispatch.py | livekit-ffi/src/server/room.rs | examples/agent-dispatch/index.ts
f
in the entrypoint function, this is what i do:
Copy code
await session.start(agent=agent, room=ctx.room, room_input_options=RoomInputOptions(participant_kinds=[rtc.ParticipantKind.PARTICIPANT_KIND_STANDARD]))
    
    await ctx.connect()
    
    await ctx.agent.set_name("Candidate")
t
It looks like the issue with
ctx.agent.set_name
not working as expected when multiple agents join the room might be related to how
RoomInputOptions
is set up. By default, LiveKit filters participants by their kind, and agents are identified as
PARTICIPANT_KIND_AGENT
, not
PARTICIPANT_KIND_STANDARD
. This means agents might not see each other unless we explicitly configure it that way. To help fix this, you can update your
RoomInputOptions
to include
PARTICIPANT_KIND_AGENT
like this:
Copy code
room_io = RoomIO(
    session,
    room=ctx.room,
    input_options=RoomInputOptions(
        participant_kinds=[rtc.ParticipantKind.PARTICIPANT_KIND_AGENT]
    )
)
Another approach some use is the
listen_to_agents=True
flag, but please note that this depends on the SDK version you’re working with. Once you have agents set up to detect each other, the
set_name
method should start working smoothly. If you run into any more questions or need a hand with this, feel free to reach out—I’m here to help! Sources: Runtime/Scripts/Participant.cs | livekit/src/room/participant/local_participant.rs | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Parti... | pkg/rtc/participant.go | How to Enable Agent-to-Agent Speech Detection in LiveKit
f
now what should i do with the roomio object after i created it, should i pass it to somewhere?
t
Once you create the
room_io
object, you can use it to manage the room's input and output streams. A great way to do this is by passing it to the session or context where the room is being managed. For example:
Copy code
await session.start(agent=agent, room=ctx.room, room_io=room_io)
This helps ensure that the updated
RoomInputOptions
configuration is properly applied to the session. It allows agents to detect each other and makes the
set_name
method work just as you’d expect. If anything’s unclear or you’d like a bit more help, please don’t hesitate to ask—I’m here for you!
f
this is causing other errors to pop up. if the participant kind is he issue, i am already giveng that in the session.start function explicitly right?
t
You're absolutely right that specifying
participant_kinds
in the
session.start
function directly sets which participant kinds the agent will process. This parameter works alongside
RoomInputOptions
and doesn’t override it, but instead determines the participant kinds the agent will auto-subscribe to during the session. If you’ve already included
PARTICIPANT_KIND_AGENT
in the
participant_kinds
list within
session.start
, then the issue might lie elsewhere. Could you please share the specific errors you’re seeing? That way, I can better understand what’s going on and help you find the right solution. Sources: metrics/metrics_tts.py | examples/voice_agents/weather_agent.py
f
there is no error. the issue is that the agent name is not being set correctly
t
Thank you so much for the clarification! It sounds like the agent name not being set correctly might be related to the timing of when
ctx.agent.set_name
is called. Here are a few things to check that might help: • Make sure the agent is fully connected to the room before you call
set_name
. • Double-check that the
set_name
method is being called on the right agent instance. • Look out for any conflicting calls or overrides that could be resetting the name after it’s set. To dig a little deeper, you could try logging the agent’s name right after calling
set_name
. This way, you can see if the name updates locally but isn’t showing up in the room. Please feel free to let me know how it goes or if you’d like me to help you investigate further—I’m here to support you!
f
I tried printing the name i set for agent like this:
Copy code
# Start the session
    await session.start(agent=agent, room=ctx.room, room_input_options=RoomInputOptions(participant_kinds=[rtc.ParticipantKind.PARTICIPANT_KIND_AGENT]))

    await ctx.connect()

    await asyncio.sleep(SLEEP_1)

    await ctx.agent.set_name("Interviewer")

    <http://logger.info|logger.info>(f"Interviewer agent started with name {ctx.agent.name}")
It cam eblank.
t
It looks like the reason
ctx.agent.name
is coming up blank is probably because the agent's name isn’t being set when the initialization happens. In LiveKit, you’ll want to define the agent’s name right when you accept a job request using the
req.accept()
method. Here’s a little example to help clarify:
Copy code
async def request_fnc(req: JobRequest):
    await req.accept(
        name="Interviewer",  # This sets the agent's name
        identity="identity",
        attributes={"myagent": "rocks"},
    )
Just make sure the
name
parameter is included during the job acceptance step. If it’s missing there, the name will stay blank. Please feel free to reach out if you’d like me to walk you through it or if you have any other questions—I’m here to help! Sources: Anatomy of an Agent | LiveKit Docs | livekit/src/room/participant/local_participant.rs | Runtime/Scripts/Participant.cs | livekit-rtc/livekit/rtc/_proto/room_pb2.pyi | SIP troubleshooting guide | LiveKit Docs
f
Copy code
if __name__ == "__main__":
    cli.run_app(WorkerOptions(
        agent_name="interviewer",
        prewarm_fnc=prewarm,
        entrypoint_fnc=entrypoint
    ))
This is how i am running the agent right now. i am providing the agent_name.
t
Thanks for sharing about the
agent_name
in
WorkerOptions
! Setting this does indeed assign the agent's name in LiveKit. This setup is especially useful for explicit agent dispatch, which means the agent will join rooms only when they’re explicitly dispatched through the
AgentDispatchService
API, a dispatch rule, or via metadata in a participant's access token. If you’re not seeing the agent name as expected, here are a couple of things to double-check: • Make sure the
agent_name
exactly matches the name used in your dispatch rules or API calls. • Check if there might be any conflicting settings or code that could be resetting the name after initialization. Please feel free to reach out if you’d like me to help you troubleshoot further or if the issue continues—I’m here to help! Sources: Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | livekit-agents/livekit/agents/worker.py | agents/src/worker.ts | Agents telephony integration | LiveKit Docs
f
tried giving name through request function. That also not working. I am still getting the name to be "simulated_agent_98983"
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!