in the `entrypoint` function - first I do: `sessio...
# ask-ai
v
in the
entrypoint
function - first I do:
session = AgentSession[ExpenseData](....
and then:
session.userdata = ExpenseData(job_context=job_context, participant_name=name)
and then I do
await session.start(..
is this correct? and then how do I access the participant name later within a tool call?
t
Thanks for reaching out, Ruchir. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like you’re on the right track with initializing the
AgentSession
and setting
session.userdata
. To access the
participant_name
later in a tool call, you can simply retrieve it from
context.userdata
within your function tool implementation. Here’s a friendly example of how you might define a function tool to get the participant name:
Copy code
@function_tool
async def get_participant_name(self, context: RunContext[ExpenseData]) -> str:
    expense_data = context.userdata
    return expense_data.participant_name
If you have any questions or want me to walk you through this further, just let me know—I’m here to help! Sources: rpc/rpc_agent.py | examples/voice_agents/silent_function_call.py | agent.py
🙌 1