Class RunContext<UserData>

Type Parameters

  • UserData = UnknownUserData

Constructors

Properties

functionCall: FunctionCall
speechHandle: SpeechHandle

Accessors

Methods

  • Speak filler audio while a long-running tool step is in progress.

    The scheduler waits until the session is continuously idle for RunContextFillerOptions.delay milliseconds, then speaks source through AgentSession.say. When interval is set, it waits that many milliseconds before starting another idle dwell; otherwise it fires at most once. Agent speech, user speech, and RunContext.update reset any pending dwell so filler does not race real conversation turns.

    Type Parameters

    • T

    Parameters

    • source: FillerSource
    • fn: (() => T | Promise<T>)
        • (): T | Promise<T>
        • Returns T | Promise<T>

    Returns Promise<T>

    Example

    await ctx.filler('Still searching, hang on.', { delay: 5000 }, async () => {
    return await slowLookup();
    });
  • Type Parameters

    • T

    Parameters

    • source: FillerSource
    • options: RunContextFillerOptions
    • fn: (() => T | Promise<T>)
        • (): T | Promise<T>
        • Returns T | Promise<T>

    Returns Promise<T>

  • Type Parameters

    • T

    Parameters

    • fn: ((activity) => T | Promise<T>)
        • (activity): T | Promise<T>
        • Parameters

          • activity: AgentActivity

          Returns T | Promise<T>

    Returns Promise<T>

  • Report progress from a long-running tool — and, on the first call, turn the tool non-blocking so the conversation continues while execute() keeps running.

    Behavior depends on whether this is the first update() for the call:

    • First call: resolves the pending tool result with message and marks the function call non-blocking (functionCall.extra.__livekit_agents_tool_non_blocking = true). The framework treats message as the tool's immediate output to the LLM and returns control to the session, so the agent can speak/listen while the tool continues in the background. Whatever execute() ultimately returns is delivered later as a deferred reply.
    • Subsequent calls: each message is enqueued via the owning executor and delivered as a fresh assistant turn, gated on the session being idle (so updates never talk over the user). The arrival cadence is therefore conversational, not immediate.

    Message rendering:

    • A string is rendered through a template — RunContextUpdateOptions.template if provided, otherwise the executor's configured updateTemplate — with {functionName}, {callId}, and {message} substituted. The default template tells the model the task is still running and not to fabricate results.
    • A non-string value is used as-is (no templating), letting a tool emit structured output.

    Every update is also recorded in RunContext.updates (with a _update_N call-id suffix for the 2nd and later updates) so the full progress trail is preserved in chat history.

    No-op for delivery when the tool isn't attached to an async-capable executor (e.g. a plain blocking tool): the update is still recorded but nothing is sent.

    Parameters

    • message: unknown

      Progress text (templated) or a structured value (sent verbatim).

    • options: RunContextUpdateOptions = {}

      Per-call overrides; see RunContextUpdateOptions.

    Returns Promise<void>

  • Waits for the speech playout corresponding to this function call step.

    Unlike SpeechHandle.waitForPlayout, which waits for the full assistant turn to complete (including all function tools), this method only waits for the assistant's spoken response prior to running this tool to finish playing.

    Returns Promise<void>