unmute_core.prefetch fills the call state before the greeting. It reads the clock, the call’s numbers and the result of a lookup. If you already have what a lookup needs, the model should not spend the call doing it.
In the salon tutorial, Know the time before hello builds this step by step.
Fill values before the greeting
List the entries. Each one saves values into the call state.agent.py
Clockreads the time in the zone you name.CallValuecopies a value the call carries.Lookupruns your function, which takes the call state and returns a mapping, like{"name": "Ana Ruiz"}.- All entries share one budget, 2 seconds by default. A late or failed entry keeps its default, and the call greets on time.
- With
state=State, a mistake in an entry raisesValueErrorwhen you build it, not during a call.
Look up with a tool
A lookup may run a tool instead of a function. Lock every argument the tool needs.- The model never fills an argument. An open required one raises
ValueErrorwhen you build the entry. - A tool that is refused or fails keeps the values at their defaults.
Run a slow lookup beside the greeting
Mark a slow lookupbackground=True, so it does not delay the greeting.
prefetch.runskips it.CallHooksruns it beside the greeting.- Every model request waits for it, up to
first_request_timeout_s(10 seconds). A fixed greeting plays at once. - A greeting line may not name a value that only a background lookup fills.
Use it in a call
Give the prefetch toCallHooks. open_call runs it for you.
open_callruns your checks first, thenprefetch.run, then the background lookups and the greeting.- Each lookup’s result goes to
call.results, so a task step can read it. - On a plain agent, run
await prefetch.run(state)yourself before the session starts.render_promptcomes fromunmute_core.model.
What a call carries
A phone number with no plus is read in the call’s country. Enteruse_phone_region around the call, so the state can read a national number.
call_phone_region(state.call)gives the call’s country, like"ES", orNonefor a call without numbers.sip_call_info(LiveKit) andtelephony_call_info(Pipecat) build what the call carries. See Telephony.
Try a phone call locally
A web session has no phone line. To try a phone call, simulate one withUNMUTE_CALL_START:
CallValue then copies the simulated number, as it would copy a real one. See State for the rules.
Where to go next
Prefetch reference
Every entry, argument, check and rule.
State
How saved values read in a prompt, and when the caller confirms them.
The call's life
The order of a whole call, and the greeting.
Prefetch on Unmute
The same entries, declared in
agent.yaml.