This question originally came up in our Slack community and the thread has been consolidated here for long-term reference.
I’m new to LiveKit and deployed my first agent. Now I want to provide agent context related to the user.
How would I do this? All the examples and demos I’ve seen just hardcode the values.
You can use the concept of userdata to pass user-specific context:
For examples, see the drive-thru agent which uses userdata to build the user’s menu items:
https://github.com/livekit-examples/python-agents-examples/tree/main/complex-agents/drive-thru/drive-thru-agentn
If you need to persist data across different sessions, store the data externally and retrieve it. The personal_shopper example shows how to persist customer orders in a database:
That same example also shows how to use a function tool to retrieve the user’s name dynamically.