red-television-3815
07/29/2025, 6:33 PMtall-airline-16756
07/29/2025, 6:33 PMtall-airline-16756
07/29/2025, 6:34 PMJobContext object. Each worker is assigned a unique string-based worker_id when it registers with the LiveKit server. Here's how you can access it:
async def entrypoint(ctx: JobContext):
# Access the worker ID
worker_id = ctx.worker_id
print(f"Agent running on worker: {worker_id}")
# Your agent logic here
await ctx.connect()
The worker_id is a string identifier, not a numeric value. If you need a numeric representation, you can hash or convert the string ID in your application code.
Sources: livekit-agents/livekit/agents/worker.py | livekit/livekit_agent.pb.go