bright-plumber-93445
05/08/2025, 1:22 PMtall-airline-16756
05/08/2025, 1:22 PMtall-airline-16756
05/08/2025, 1:22 PMagent.update_tools()
. However, tools can access the current session, agent, and state through a special context
argument of type RunContext
, which provides access to the current session, function call, speech handle, and userdata.
If you need further clarification or have a specific use case in mind, feel free to share more details!
Sources: Tool definition and use | LiveKit Docsbright-plumber-93445
05/08/2025, 1:28 PMtall-airline-16756
05/08/2025, 1:29 PMJobContext
class using the agent
accessor property. This property returns the agent's participant if connected to the room, or undefined
if not connected.
Here is an example:
// Accessing the agent property from a JobContext instance
const agentParticipant = jobContext.agent;
Sources: JobContext | LiveKit Agentsbright-plumber-93445
05/08/2025, 1:36 PMtall-airline-16756
05/08/2025, 1:37 PMRunContext
by accessing the userdata
property. Here is an example:
@function_tool()
async def update_name(
name: Annotated[str, Field(description="The customer's name")],
context: RunContext_T,
) -> str:
"""Called when the user provides their name.
Confirm the spelling with the user before calling the function."""
userdata = context.userdata
userdata.customer_name = name
return f"The name is updated to {name}"
In this example, the userdata
is accessed through context.userdata
, and the desired property (e.g., customer_name
) is modified directly.
Sources: Tree View: | dse-workbenchbright-plumber-93445
05/08/2025, 1:41 PMtall-airline-16756
05/08/2025, 1:41 PMValueError: VoiceAgent userdata is not set
occurs when you try to access the userdata
property of a VoiceAgent
instance without setting it first. To resolve this, you need to ensure that the userdata
is set before accessing it.
You can do this in one of two ways:
1. Pass the userdata
parameter when initializing the `VoiceAgent`:
agent = VoiceAgent(userdata=your_data)
1. Set it after initialization using the setter:
agent = VoiceAgent()
agent.userdata = your_data
Ensure that your_data
is properly defined before assigning it to avoid this error.
Sources: livekit.agents API documentation