What is the point of maintaining user_data if all ...
# ask-ai
g
What is the point of maintaining user_data if all the data will anyway live in the prompt
t
Thanks for reaching out, Aumesh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m glad you asked about the role of
user_data
! Its main purpose is to hold dynamic, session-specific information that helps the agent respond thoughtfully and keep track of the conversation over time. While prompts give the agent a starting point or general instructions,
user_data
lets the agent remember and update details during your session—like who you are, where you left off, or special info like flash cards or quizzes. Let me give you an example: imagine you’re chatting with a personal shopper. The
user_data
would store your name, ID, and current order details, so the agent can tailor its responses just for you. It also helps keep things running smoothly behind the scenes, especially when switching between different agents, by preserving important context. This makes the whole experience more reliable and seamless. So, to sum it up, prompts guide how the agent acts, while
user_data
holds what the agent remembers about you and your session—helping create a more personalized and meaningful interaction. Sources: avatars/tavus/tavus.py | Building an Automated IVR Menu Caller | LiveKit Docs | Building Multi-Agent Architectures with LiveKit Agents
g
Won't the session context have this already?
t
Thanks for your question! When we talk about "session context," it’s often used informally to describe the overall runtime environment during an agent session. However, in LiveKit, it’s not defined as a distinct standalone concept. Instead, the key way to keep track of persistent, session-specific information is through
user_data
.
user_data
is a user-defined, serializable object that stays with the session throughout its lifecycle. It’s a great tool for agents to store and update important details—like user information or the conversational state—that aren’t automatically part of the runtime environment. This helps make sure that essential session data is clearly managed and easily accessible, even when moving between functions or agent transitions. If you had a particular aspect of "session context" in mind, please feel free to share more details. I’d be happy to provide more focused help! Sources: agents/src/voice/agent_session.ts | Building Multi-Agent Architectures with LiveKit Agents | Workflows | LiveKit Docs | examples/drive-thru/drivethru_agent.py | flows/declarative_flow.py