jolly-apartment-95291
06/06/2025, 3:25 AMtall-airline-16756
06/06/2025, 3:25 AMtall-airline-16756
06/06/2025, 3:25 AMuserdata property of the session or context object. Here are two examples: 1. Using function tools, you can update userdata via the context parameter:
@function_tool()
async def confirm_expense(
self,
expense: Annotated[float, Field(description="The expense of the order")],
context: RunContext_T,
) -> str:
"""Called when the user confirms the expense."""
userdata = context.userdata
userdata.expense = expense
return f"The expense is confirmed to be {expense}"
2. When transferring between agents, you can pass and update userdata:
@function_tool
async def information_gathered(
self,
context: RunContext[StoryData],
name: str,
location: str,
):
context.userdata.name = name
context.userdata.location = location
story_agent = StoryAgent(name, location)
return story_agent, "Let's start the story!"
The userdata is available as session.userdata and is also accessible within function tools on the RunContext. Let me know if you need further clarification! Sources: Tree View: | dse-workbench | Workflows | LiveKit Docs