shy-train-51607
09/02/2025, 12:53 PMasync def entrypoint(ctx: JobContext):
"""
Main entry point for the agent worker - handles inbound/outbound calls
"""
print(ctx.job)
...
and I'm using the following command to make the call:
lk --project development dispatch create \
--new-room \
--agent-name my-telephony-agent \
--metadata 'foo'
Using project [development]
Dispatch created: id:"AD_QBCpejWRFdLH" agent_name:"my-telephony-agent" room:"room-5tYmBygSMCnT" metadata:"foo" state:{created_at:1756817153983250007}
but looking at the printed logs I don't see any metadata:
id: "AJ_PuNzxb9iqYQt"
room {
sid: "RM_EneXZhGWfcCB"
name: "room-4nM5uniACPBC"
empty_timeout: 300
creation_time: 1756817537
enabled_codecs {
mime: "video/H264"
}
enabled_codecs {
mime: "video/VP8"
}
enabled_codecs {
mime: "video/VP9"
}
enabled_codecs {
mime: "video/AV1"
}
enabled_codecs {
mime: "audio/red"
}
enabled_codecs {
mime: "audio/opus"
}
version {
unix_micro: 1756817537065403
}
departure_timeout: 20
creation_time_ms: 1756817537049
}
state {
status: JS_RUNNING
started_at: 1756817537519467213
updated_at: 1756817537519467213
worker_id: "AW_A8w5qUaVboo9"
agent_id: "A_fFk383vGUpRV"
}
What am I missing? Why is there no metadata in the job context?tall-airline-16756
09/02/2025, 12:53 PMtall-airline-16756
09/02/2025, 12:54 PMJobContext under ctx.job.metadata. But it looks like it’s not showing up in your logs right now. No worries though—here are a few things you can check to get it sorted:
1. Make sure the metadata is passed as a string. If you’re sending structured data, use JSON. For example: --metadata '{"key":"value"}'.
2. In your agent’s code, try logging ctx.job.metadata directly to see if it’s there. Something like this works:
import json
async def entrypoint(ctx: JobContext):
metadata = ctx.job.metadata
print(f"Metadata: {metadata}")
if metadata:
parsed_metadata = json.loads(metadata)
print(f"Parsed Metadata: {parsed_metadata}")
1. Double-check that your agent is registered correctly with the agent_name you’re using in the dispatch command.
2. Take a look at the dispatch creation response to see if the metadata is included there. If it’s missing, the issue might be with how the dispatch command is set up.
If you’re still running into trouble after trying these steps, just give me a shout! I’m here to help you figure it out.
Sources: examples/agent_dispatch.py | examples/agent-dispatch/index.ts | flows/declarative_flow.py | Agent dispatch | LiveKit Docs | Job lifecycle | LiveKit Docsshy-train-51607
09/02/2025, 12:58 PMagent_name mandatory for this to work properly? My agent does get the job currently so it seems to be dispatched as expected, but still the metadata can't be found in the job contexttall-airline-16756
09/02/2025, 12:58 PMagent_name isn’t directly tied to the metadata itself, but it’s super important for enabling explicit dispatch. This is the feature that lets metadata get passed along to the JobContext. Without setting agent_name, explicit dispatch won’t work, and your job context won’t include the metadata.
Since your agent is receiving the job, it looks like dispatch is happening, but the missing metadata hints that explicit dispatch might not be fully set up yet. Here are a few things to double-check:
1. Make sure the agent_name is included in the dispatch command or configuration.
2. Confirm that the metadata is being sent as a string (JSON is usually best) in the dispatch command.
3. Try explicitly logging ctx.job.metadata in your agent’s entrypoint to see if it’s there.
If you’ve already done all this and it’s still not working, just give me a shout and we’ll dig into it together!
Sources: Dispatching agents | LiveKit Docs | livekit-protocol/livekit/protocol/agent.py | Making calls using SIP | LiveKit Docsshy-train-51607
09/02/2025, 1:02 PMtall-airline-16756
09/02/2025, 1:02 PMagent_name did the trick. If anything else comes up or you have more questions, just give me a shout—I'm here to help!clean-architect-57780
09/02/2025, 3:25 PMtall-airline-16756
09/02/2025, 3:25 PMroom_id where you’re seeing these duplicate dispatches.
• Any patterns or situations you’ve noticed when the duplicates happen (like during high load or certain settings).
Once I have this info, I’ll do my best to help you figure out what’s going on and get it sorted out.shy-train-51607
09/02/2025, 3:27 PMtall-airline-16756
09/02/2025, 3:27 PM