Skip to main content
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
  1. Clock reads the time in the zone you name. CallValue copies a value the call carries. Lookup runs your function, which takes the call state and returns a mapping, like {"name": "Ana Ruiz"}.
  2. All entries share one budget, 2 seconds by default. A late or failed entry keeps its default, and the call greets on time.
  3. With state=State, a mistake in an entry raises ValueError when 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.
  1. The model never fills an argument. An open required one raises ValueError when you build the entry.
  2. A tool that is refused or fails keeps the values at their defaults.

Run a slow lookup beside the greeting

Mark a slow lookup background=True, so it does not delay the greeting.
  1. prefetch.run skips it. CallHooks runs it beside the greeting.
  2. Every model request waits for it, up to first_request_timeout_s (10 seconds). A fixed greeting plays at once.
  3. A greeting line may not name a value that only a background lookup fills.

Use it in a call

Give the prefetch to CallHooks. open_call runs it for you.
  1. open_call runs your checks first, then prefetch.run, then the background lookups and the greeting.
  2. Each lookup’s result goes to call.results, so a task step can read it.
  3. On a plain agent, run await prefetch.run(state) yourself before the session starts. render_prompt comes from unmute_core.model.

What a call carries

A phone number with no plus is read in the call’s country. Enter use_phone_region around the call, so the state can read a national number.
  1. call_phone_region(state.call) gives the call’s country, like "ES", or None for a call without numbers.
  2. sip_call_info (LiveKit) and telephony_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 with UNMUTE_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.