m
hi
t
Thanks for reaching out, Rahib. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd love to help you out! Could you please share a bit more about your question or the issue you're experiencing? That way, I can assist you in the best possible way.
m
if i do setup something in prewarm function like a class that handles my csv file and load client data how do i access that in the main Agent?
t
I'm glad you asked about accessing a class or object initialized in the
prewarm
function within the main Agent! A helpful way to do this is by storing the object in the
proc.userdata
dictionary during the
prewarm
phase. Then, you can easily access this userdata in the
entrypoint
function using
ctx.proc.userdata
. Here's a simple example to illustrate: Prewarm Function:
Copy code
def prewarm(proc: JobProcess):
    proc.userdata["csv_handler"] = CSVHandler(client_data)
Entrypoint Function:
Copy code
async def entrypoint(ctx: JobContext):
    csv_handler = ctx.proc.userdata["csv_handler"]  # Accessing prewarmed object
    # Use csv_handler as needed
This method helps keep things efficient and speeds up your agent’s startup time. If anything feels unclear or if you’d like a hand with this, please don’t hesitate to reach out—I’m here to help! Sources: Worker options | LiveKit Docs | agent/main.py | ivr-nagivator/README.mdoc
m
Will this also fill the llm context or is this always stays in the userdata and dosent affect llm ?
t
Thanks for your question! Just to clarify, the data stored in
proc.userdata
during the
prewarm
phase doesn’t automatically influence the LLM context. Think of
proc.userdata
as a place to keep persistent data or resources for the agent process, but it stays separate from the LLM’s conversational context. If you’d like to shape the LLM context, you’ll want to explicitly set or update the
chat_ctx
parameter when you create an agent, start a session, or handle responses. For example, you can preload user-specific information into
chat_ctx
to make the conversation feel more personalized and relevant. Please feel free to reach out if you’d like some help with setting up
chat_ctx
or integrating your data into the LLM context—I’m here to help! Sources: Voice Assistant Applications | livekit/livekit_composite | DeepWiki | agent/main.py | livekit-agents/livekit/agents/voice/agent_session.py | External data and RAG | LiveKit Docs | examples/src/restaurant_agent.ts
m
awesome and then i can pass it to agent init ?
t
Absolutely! You can definitely pass data from
proc.userdata
to your agent during initialization. For instance, if you store a resource like a preloaded model in
proc.userdata
during the
prewarm
phase, you can easily retrieve it later in the
entry
function and pass it to your agent when initializing. Here’s a simple example to illustrate this: Prewarm Function:
Copy code
def prewarm(proc: JobProcess):
    proc.userdata["csv_handler"] = CSVHandler(client_data)
Entrypoint Function:
Copy code
async def entrypoint(ctx: JobContext):
    csv_handler = ctx.proc.userdata["csv_handler"]  # Accessing the prewarmed object
    agent = MyAgent(csv_handler=csv_handler, ...)
This approach helps you reuse resources efficiently that were set up during
prewarm
. If you have any questions or need a hand with this, please don’t hesitate to ask—I’m here to help! Sources: examples/src/drive-thru/drivethru_agent.ts | complex-agents/drive-thru/session_setup.py | Workflows | LiveKit Docs
m
Now if i want to make a phone lookup in this csv data to find the user based on the inbound call phone number where should i do that and how should I do that ?
t
Thanks for reaching out! Could you please share a bit more about where you'd like to perform the phone lookup? For instance: • Would you prefer the lookup to happen when the agent is initializing? • Or should it take place dynamically while the agent is handling an inbound call? Also, it would be great to know if you're looking for some tips on organizing the CSV data or if you need help with setting up the lookup logic itself. I'm here to help you through it!
m
The first point where we can receive the phone number at that place I want to do the lookup
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!