fix: extract auth header from job.metadata instead of agent_dispatch
LiveKit passes RoomAgentDispatch metadata through as job.metadata (protobuf field), not via a separate agent_dispatch object. Also use room_io.RoomInputOptions for participant targeting (livekit-agents 1.x). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f1d50e43f1
commit
23b5bce983
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue