creamy-tiger-14805
09/10/2025, 1:25 PMtall-airline-16756
09/10/2025, 1:25 PMtall-airline-16756
09/10/2025, 1:26 PMjob.metadata
field in LiveKit! This field is a flexible, freeform string where you can include any data you'd like to pass along to an agent job. To keep things organized, LiveKit suggests using JSON or similar structured formats, especially if you want to share complex or multiple pieces of information.
For instance, you might want to include details like user_id
, user_name
, and user_phone
within a JSON string. This way, the agent can easily parse and use these values, like in the example below:
import json
async def entrypoint(ctx: JobContext):
metadata = json.loads(ctx.job.metadata)
user_id = metadata["user_id"]
user_name = metadata["user_name"]
user_phone = metadata["user_phone"]
When you dispatch a job through the API or CLI, you set the actual content of job.metadata
. Feel free to include any key-value pairs you need, encoded as a string. There aren’t any strict restrictions on the fields—just keep in mind the practical limits like string size and JSON parsing.
If you have any more questions or want to explore this further, I'm here to help!
Sources: Job lifecycle | LiveKit Docs | Agent dispatch | LiveKit Docs | cmd/lk/token.go