what's the difference between agent's name and ide...
# ask-ai
a
what's the difference between agent's name and identity?
t
Thanks for reaching out, affandy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just a quick heads-up about the agent's name and identity in LiveKit—they each have their own special role: • Name: This is an optional display name you can set for the participant. It’s what shows up in the UI or labels, making it easier to recognize who’s who. For example, you might call it "Customer Support Bot" so it feels more personal. • Identity: This one’s a must-have! It’s a unique ID for the participant within a room, used behind the scenes by LiveKit to keep track of everyone. It’s super important for things like RPC calls and other programmatic actions. Here’s a quick example for when you’re accepting a job request—you can set both like this:
Copy code
await req.accept(
  name="agent",        # Display name
  identity="identity"  # Unique identifier
)
So, to wrap it up: use name when you want something friendly and readable for people, and identity when you need a unique, programmatic ID. Hope that clears things up! Sources: Anatomy of an Agent | LiveKit Docs | Worker options | LiveKit Docs | src/components/playground/Playground.tsx | Rooms, participants, and tracks | LiveKit Docs
a
I've set the agent name like the following. but in participant list my agent doesn't have the name as I specified there.
Copy code
if __name__ == "__main__":
    agents.cli.run_app(
        agents.WorkerOptions(
            entrypoint_fnc=entrypoint,
            # prewarm_fnc=prewarm,
            agent_name=f"latifah-english",
        )
    )
t
Hey there! Just a quick heads-up: the
agent_name
you set in the code is actually an attribute of the agent worker or job, not the participant itself. That’s why it doesn’t show up in the participant list. Instead, agents are identified in the participant list by their
kind
field, which will be set to
AGENT
. The
agent_name
mainly comes into play during the dispatch process to decide which agent gets assigned to a room, but it’s not visible as a public field in the participant list. If you want to keep track of which agent with a certain
agent_name
joined a room, you can match this info using backend logs, the agent dispatch API, or by checking out job metadata through the server SDKs. If you have any more questions or need a hand with this, just let me know—I’m here to help! Sources: Core API primitives | LiveKit Docs | Dispatching agents | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | livekit-protocol/src/livekit.rs | JobRequest | LiveKit Agents
a
can you show me how to do it?
t
Here are three easy ways to keep track of the
agent_name
in LiveKit: 1. Using Job Metadata: You can add metadata during the dispatch process and then access it in the agent's
JobContext
. Here's a quick example:
Copy code
async def entrypoint(ctx: JobContext):
    logger.info(f"Job metadata: {ctx.job.metadata}")
    metadata = json.loads(ctx.job.metadata)
Just set the metadata when you create a dispatch like this:
Copy code
dispatch = await lkapi.agent_dispatch.create_dispatch(
    api.CreateAgentDispatchRequest(
        agent_name="test-agent",
        room="my-room",
        metadata='{"user_id": "12345"}'
    )
)
1. Using Backend Logs: You can also add the
agent_name
to your logs using `ctx.log_context_fields`:
Copy code
async def entrypoint(ctx: JobContext):
    ctx.log_context_fields = {
        "worker_id": ctx.worker_id,
        "room_name": ctx.room.name,
        "agent_name": ctx.job.agent_name,
    }
These logs can then be easily reviewed with your existing logging tools. 1. Using the Agent Dispatch API: You can query dispatch records to get the
agent_name
like this:
Copy code
dispatches = await lkapi.agent_dispatch.list_dispatch(room_name="my-room")
for dispatch in dispatches:
    print(f"Agent {dispatch.agent_name} dispatched to {dispatch.room}")
If you want me to walk you through any of these or need a hand setting them up, just let me know—I'm happy to help! Sources: Dispatching agents | LiveKit Docs | Dispatching agents | LiveKit Docs | Agent dispatch | LiveKit Docs | Job lifecycle | LiveKit Docs | protobufs/livekit_agent_dispatch.proto