thousands-car-74964
08/28/2025, 2:00 AMtall-airline-16756
08/28/2025, 2:00 AMtall-airline-16756
08/28/2025, 2:01 AMmetadata field in your dispatch request. For example:
// Node.js Example
const dispatch = await agentDispatchClient.createDispatch(roomName, agentName, {
metadata: '{"prompt_type": "support", "user_id": "12345"}',
});
• Using a Participant Token: You can also embed the agent dispatch setup, including metadata, right into the participant’s access token with RoomConfiguration. Like this:
// Node.js Example
at.roomConfig = new RoomConfiguration({
agents: [
new RoomAgentDispatch({
agentName: agentName,
metadata: '{"department": "technical_support"}',
}),
],
});
How to use metadata in your agent:
Inside your agent’s entrypoint, just parse the metadata to decide which prompt or context fits best:
import json
async def entrypoint(ctx: JobContext):
metadata = json.loads(ctx.job.metadata)
prompt_type = metadata.get("prompt_type", "default")
if prompt_type == "support":
instructions = "You are a technical support agent..."
elif prompt_type == "billing":
instructions = "You are a billing specialist..."
else:
instructions = "You are a general assistant..."
agent = MyAgent(instructions=instructions)
await agent.start(ctx)
This way, you get dynamic, metadata-driven routing and personalization for your agent’s prompts and workflows. If you have any questions or want me to walk you through this, just let me know—I’m happy to help!
Sources: examples/agent-dispatch/index.ts | examples/agent_dispatch.py | Job lifecycle | LiveKit Docs | Workflows | LiveKit Docs | Agent dispatch | LiveKit Docsthousands-car-74964
08/28/2025, 2:05 AMtall-airline-16756
08/28/2025, 2:05 AMthousands-car-74964
08/28/2025, 2:11 AM