brash-wire-35118
07/21/2025, 3:09 PMtall-airline-16756
07/21/2025, 3:09 PMtall-airline-16756
07/21/2025, 3:10 PMroom_name in all logs depend on this detail.brash-wire-35118
07/21/2025, 3:10 PMtall-airline-16756
07/21/2025, 3:11 PMctx.log_context_fields in your Python agent's entrypoint function, you can automatically include the room_name in every single log entry. It's like adding a helpful little tag to all your logs!
Here's a quick example to show you how:
async def entrypoint(ctx: JobContext):
ctx.log_context_fields = {
"room_name": ctx.room.name,
}
# ... rest of your code ...
Pro tip: You can totally add more fields if you want. Now all your job logs will include the room_name right in their JSON structure, making debugging and tracking so much easier. Pretty neat, right?brash-wire-35118
07/21/2025, 3:11 PMtall-airline-16756
07/21/2025, 3:12 PMroom_name isn't showing up in your logs. I know this can be frustrating, but we'll solve it together.
• First, make sure you're setting ctx.log_context_fields in your entrypoint function after JobContext is initialized. Double-check that ctx.room.name has a valid value when you do this.
• Take a look at how you're assigning the dictionary. It should look something like this:
ctx.log_context_fields = {
"room_name": ctx.room.name,
"worker_id": ctx.worker_id,
}
• Pro tip: Try adding another field like worker_id to see if it shows up in the logs. If it does, but room_name doesn't, there might be an issue with ctx.room.name.
• Do a quick scan of your code to make sure you're not accidentally overwriting the log context fields later on.
• Lastly, confirm that your job is running in the right execution context and that the room connection is set up correctly.
Still no luck? Let me know if other fields from ctx.log_context_fields are appearing, or if none of the custom fields are showing up. We'll get to the bottom of this!
Sources: Job lifecycle | LiveKit Docs | livekit-agents/livekit/agents/ipc/job_proc_lazy_main.pybrash-wire-35118
07/21/2025, 3:15 PMtall-airline-16756
07/21/2025, 3:16 PM