adorable-bear-14321
04/06/2026, 1:53 PMtall-airline-16756
04/06/2026, 1:53 PMtall-airline-16756
04/06/2026, 1:54 PMctx.log_context_fields to include the worker configuration you care about (e.g., worker_id, room_name, drain_timeout, permissions, load_threshold, any custom options).
◦ Example pattern:
@server.rtc_session(agent_name="my-agent")
async def my_agent(ctx: JobContext):
ctx.log_context_fields = {
"worker_id": ctx.worker_id,
"room_name": ctx.room.name,
"drain_timeout": my_worker_options.drain_timeout,
"permissions": my_worker_options.permissions,
"load_threshold": my_worker_options.load_threshold,
}
ctx.log.info("worker options logged", extra=ctx.log_context_fields)
1. Increase verbosity if needed
◦ Set --log-level=DEBUG or LIVEKIT_LOG_LEVEL=DEBUG to capture more detailed logs.
1. Retrieve logs
◦ Stream live logs with the CLI: lk agent logs --id <agent-id>.
◦ View stored logs in the cloud dashboard under Agent insights → Logs (note: logs for completed sessions are not real-time and are retained for a limited time).
◦ Forward logs to an external service (Datadog, CloudWatch, Sentry, New Relic) by configuring the appropriate secret/integration if you want centralized storage/retention.
If you want, tell me:
• which runtime (Python or Node) and agent SDK version you’re using, and
• the exact worker options you need logged (list them),
and I’ll give you the exact snippet and the recommended place to add it.
Sources: Job lifecycle | LiveKit Documentation | Where to find your Agent Logs | LiveKit | Server options | LiveKit Documentation, with interactive elementsadorable-bear-14321
04/06/2026, 1:58 PMtall-airline-16756
04/06/2026, 1:58 PMctx.log_context_fields so they become structured fields in JSON logs.
3. Optionally log a message with those fields using ctx.log.
4. Increase verbosity with --log-level=DEBUG or LIVEKIT_LOG_LEVEL=DEBUG if you need more detail.
5. Retrieve logs via lk agent logs --id <agent-id>, the cloud dashboard (Agent insights → Logs), or forward to Datadog/CloudWatch/Sentry/New Relic.
Python example (entrypoint)
@server.rtc_session(agent_name="my-agent")
async def my_agent(ctx: JobContext):
# Gather worker option values (replace with your actual option sources)
worker_options = {
"worker_id": ctx.worker_id,
"room_name": getattr(ctx.room, "name", None),
"drain_timeout": getattr(ctx, "drain_timeout", None),
"permissions": getattr(ctx, "permissions", None),
"load_threshold": getattr(ctx, "load_threshold", None),
# add any custom options here
}
# Add structured fields to logs
ctx.log_context_fields = worker_options
# Emit a log line that includes those fields
ctx.log.info("Worker options at entrypoint", extra=worker_options)
# ...rest of your agent logic...
Notes
• There is no automatic full dump of all worker options — you must enumerate and log the ones you want.
• If you want persistent central storage or longer retention, forward logs to an external service.
Tell me your SDK (Python or Node) and which exact worker options you need logged and I’ll provide a tailored snippet.
, with interactive elementsadorable-bear-14321
04/06/2026, 3:26 PMtall-airline-16756
04/06/2026, 3:26 PMctx.worker_id
• Room/job info: ctx.room (e.g., ctx.room.name) and job metadata on ctx.job where available
• Shared prewarm/worker state: ctx.proc.userData (store/retrieve data between prewarm and entry)
• Add structured log fields: ctx.log_context_fields to include worker info in JSON logs
Python example (entrypoint)
@server.rtc_session(agent_name="my-agent")
async def my_agent(ctx: JobContext):
# worker + job info
info = {
"worker_id": ctx.worker_id,
"room_name": getattr(ctx.room, "name", None),
"job_id": getattr(ctx, "job", None) and ctx.job.id,
"proc_user_data": getattr(ctx.proc, "userData", None),
}
# attach structured fields and emit a log line
ctx.log_context_fields = info
ctx.log.info("entrypoint worker info", extra=info)
# rest of agent...
Node (TypeScript) pattern
export default defineAgent({
async entry(ctx: JobContext) {
const info = {
worker_id: ctx.worker_id,
room_name: ctx.room?.name,
job_id: ctx.job?.id,
proc_user_data: ctx.proc?.userData,
};
ctx.log_context_fields = info;
ctx.log.info("entrypoint worker info", info);
}
});
Retrieving the logs
• Stream live logs: lk agent logs --id <agent-id>
• Cloud dashboard: Agent insights → Logs
• Or forward to Datadog/CloudWatch/Sentry/NewRelic for centralized retention
If you tell me your SDK (Python or Node) and the exact worker fields you want (e.g., drain_timeout, permissions, custom options), I’ll return a ready-to-drop snippet that logs every requested option.
Sources: Agents (Node.js) | livekit/livekit_composite | DeepWiki | Job lifecycle | LiveKit Documentation | Server options | LiveKit Documentation, with interactive elements