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,
|
participant.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Extract auth header from room agent dispatch metadata
|
# Extract auth header from job metadata
|
||||||
# The token endpoint embeds {"auth_header": "Bearer ..."} in dispatch metadata
|
# The token endpoint embeds {"auth_header": "Bearer ..."} via RoomAgentDispatch metadata,
|
||||||
|
# which LiveKit passes through as job.metadata to the agent worker.
|
||||||
auth_header = ""
|
auth_header = ""
|
||||||
dispatch_metadata = ctx.room.name # fallback
|
|
||||||
try:
|
try:
|
||||||
# Try to get metadata from the agent dispatch
|
meta_str = ctx.job.metadata or "{}"
|
||||||
job = ctx.job
|
meta = json.loads(meta_str)
|
||||||
if job and hasattr(job, "agent_dispatch") and job.agent_dispatch:
|
auth_header = meta.get("auth_header", "")
|
||||||
meta_str = job.agent_dispatch.metadata or "{}"
|
except Exception as e:
|
||||||
meta = json.loads(meta_str)
|
logger.warning("Failed to parse job metadata: %s", e)
|
||||||
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
|
|
||||||
|
|
||||||
logger.info("Auth header present: %s", bool(auth_header))
|
logger.info("Auth header present: %s", bool(auth_header))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue