Recipes← all recipesView on GitHub

Cover AI agent tool latency with fillers

AI AgentsAI agent tool latency fillers

Play localized filler phrases or a hosted wait file while a slow AI agent tool finishes.

tool-calling

The claim

While a tool runs, the model is not running, so nothing in your prompt can cover the gap. Three fields on the document do. fillers on the function is a phrase for the moment this tool is called. wait_file is audio the platform loops while the tool is still running, and this recipe renders it only when you host a file. function_fillers on each language entry is the pool the platform draws from for any tool, in that language.

Why it holds

Docs: SWAIG functions and multilingual.

How it works

The function carries its own filler and, when WAIT_FILE_URL is set, its wait file.

@AgentBase.tool(
    name="check_stock",
    description="Look up how many of a part are in stock by its SKU.",
    parameters={...},
    fillers={"en-US": ["Checking the warehouse now."]},
    wait_file="https://cdn.example.com/audio/hold.mp3",
    wait_file_loops=3,
)

The function-level fillers dict takes one language key. The 3.0.1 schema defines it as one-of-one-language, and the schema rejects a dict with two keys. Your per-language pools go on the languages.

self.add_language("Spanish", "es-ES", "rime.spore",
                  speech_fillers=["Vale."],
                  function_fillers=["Un momento, estoy comprobando."])
self.set_params({"languages_enabled": True})

Pass both speech_fillers and function_fillers. With only one, the SDK writes the deprecated single fillers key on the language, and the verifier shows it. Set languages_enabled, or the platform ignores the list.

The app does not host audio. You attach wait_file by setting WAIT_FILE_URL to a file the platform can fetch; with it unset, the function renders without either wait key.

Limitations

Fillers cover latency; they do not shorten it. Keep wait_file_loops low so the returning silence tells you something is wrong.

The verifier proves what the document says, not what a caller hears. The linked platform docs describe which phrase plays and when.

What to change first

Empty WAIT_FILE_URL and run the verifier. The wait_file keys disappear from the rendered function, which is the difference between promising audio and playing it.

Where this sits

Seen in a build

One of 10 recipes composed by Embed a state-aware voice agent in your web page.