diff --git a/packages/services/voice-agent/src/agent.py b/packages/services/voice-agent/src/agent.py index 8051a81..56a5003 100644 --- a/packages/services/voice-agent/src/agent.py +++ b/packages/services/voice-agent/src/agent.py @@ -102,28 +102,16 @@ async def entrypoint(ctx: JobContext) -> None: participant.name, ) - # Extract auth header from room agent dispatch metadata - # The token endpoint embeds {"auth_header": "Bearer ..."} in dispatch metadata + # Extract auth header from job metadata + # The token endpoint embeds {"auth_header": "Bearer ..."} via RoomAgentDispatch metadata, + # which LiveKit passes through as job.metadata to the agent worker. auth_header = "" - dispatch_metadata = ctx.room.name # fallback try: - # Try to get metadata from the agent dispatch - job = ctx.job - if job and hasattr(job, "agent_dispatch") and job.agent_dispatch: - meta_str = job.agent_dispatch.metadata or "{}" - meta = json.loads(meta_str) - auth_header = meta.get("auth_header", "") - except Exception: - pass - - # Fallback: try participant metadata - if not auth_header: - try: - meta_str = participant.metadata or "{}" - meta = json.loads(meta_str) - auth_header = meta.get("auth_header", "") - except Exception: - pass + meta_str = ctx.job.metadata or "{}" + meta = json.loads(meta_str) + auth_header = meta.get("auth_header", "") + except Exception as e: + logger.warning("Failed to parse job metadata: %s", e) logger.info("Auth header present: %s", bool(auth_header))