how do i set agent name in .toml file
# ask-ai
d
how do i set agent name in .toml file
t
Thanks for reaching out, Billy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand you’re looking to set the
agent_name
, and I’m here to help! This setting can’t be done directly in a
.toml
file like
livekit.toml
. Instead, you’ll want to configure it programmatically in your agent’s code using the
WorkerOptions
class. Here’s a friendly example in Python to guide you:
Copy code
if __name__ == "__main__":
    cli.run_app(
        WorkerOptions(
            entrypoint_fnc=entrypoint,
            agent_name="my-agent",  # Set agent name here
        )
    )
After setting it up, you can easily manage your agent’s dispatch behavior either through the Agent Dispatch API or by defining it in the room configuration of an access token. If you have any questions or want me to walk you through this, just let me know—I’m happy to help! Sources: Dispatching agents | LiveKit Docs | Agents telephony integration | LiveKit Docs | Deploying to production | LiveKit Docs | examples/agent-dispatch/index.ts | Agent dispatch | LiveKit Docs
d
agent name field is still blank after lk agent deploy
t
Sometimes, the
agent_name
field might look blank after you deploy using
lk agent deploy
. This happens because the deployment process itself doesn’t set or require the
agent_name
. Instead, you’ll want to explicitly define it right in your agent's code using
WorkerOptions
. Here’s a simple way to fix this: 1. Make sure you set the
agent_name
in your agent's startup code. For example:
Copy code
if __name__ == "__main__":
    cli.run_app(
        WorkerOptions(
            entrypoint_fnc=entrypoint,
            agent_name="my-agent"  # Set agent name here
        )
    )
1. Double-check that the
agent_name
matches any dispatch rules or API configurations if you’re using explicit dispatch. 2. Run
lk agent status
or
lk agent list
to see your agent’s current runtime state and confirm the name is showing up correctly. If you’re still running into trouble after this, just let me know! I’m here to help and we can dig into it together. Sources: Agent dispatch | LiveKit Docs | cmd/lk/agent.go | Agents telephony integration | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | src/components/playground/Playground.tsx
d
hmm ok because it works locally but in cloud it doesnt work...
inbound
t
It looks like the issue happens because the
agent_name
is working locally but hasn’t been properly registered or deployed in the cloud for inbound calls yet. No worries—let’s walk through some steps to get this sorted out: 1. Make Sure
agent_name
Matches:
Double-check that the
agent_name
in your agent code exactly matches the one in your dispatch rule. For example:
Copy code
# In agent.py\nWorkerOptions(\n    entrypoint_fnc=entrypoint,\n    agent_name=\"inbound-agent\"  # Must match dispatch rule\n)
Copy code
// In dispatch-rule.json\n{\n  \"room_config\": {\n    \"agents\": [\n      { \"agent_name\": \"inbound-agent\" }\n    ]\n  }\n}
1. Apply the Dispatch Rule: Run
lk sip dispatch create dispatch-rule.json
to register the rule in the cloud. 2. Verify Agent Deployment: Make sure your agent is deployed to LiveKit Cloud—not just running locally—since local execution doesn’t automatically register it in the cloud. 3. Check Active Dispatches: Use the API or CLI to list current dispatch rules and confirm your agent is included. 4. Confirm SIP Trunk: Verify that your inbound SIP trunk is active and properly linked to the dispatch rule. Could you please check if the agent has been deployed to LiveKit Cloud and if the dispatch rule is applied? I’m here to help if you need any more guidance or have questions along the way! Sources: SIP troubleshooting guide | LiveKit Docs | Accepting incoming calls | LiveKit Docs | livekit/livekit_cloud_agent.pb.go | examples/agent_dispatch.py | Agents telephony integration | LiveKit Docs
d
it works! takes a few minutes for the agent name to populate
t
I'm so happy to hear that it's working for you now! The delay in the agent name showing up is usually because the cloud system needs a little time to register and sync the agent's deployment and dispatch rules. If you have any more questions or if there's anything else I can help with, please don't hesitate to reach out. I'm here for you!