abundant-egg-29187
03/09/2026, 9:56 PMtall-airline-16756
03/09/2026, 9:56 PMtall-airline-16756
03/09/2026, 9:56 PMcontext: RunContext parameter to your tool function.
2. Call context.disallow_interruptions() at the beginning of the tool.
3. Run your asynchronous or long-running operation.
4. Return the tool result — the agent will then resume handling user input and reply using the tool’s context.
Example
@function_tool()
async def my_uninterruptible_tool(self, context: RunContext):
# Disable interruptions for this tool
context.disallow_interruptions()
# Perform the long-running async operation
result = await some_async_operation()
return result
Notes and best practices
• While interruptions are disabled, user speech will not cancel the tool or be acted on until the tool returns.
• For long operations, consider sending an in-session message (for example with session.generate_reply() before you start) to let the user know the agent is processing and will reply when the operation finishes.
• This works for both regular tools and tasks in the LiveKit Agents framework.
If you’d like, tell me:
• whether your tool is CPU-bound or network-bound,
• an expected run time, and
• if you want a user-visible progress/status update,
and I’ll suggest the best pattern (e.g., sending a pre-start reply, polling/status updates, or breaking the work into cancellable chunks).
Sources: Tool definition and use | LiveKit Documentation | External data and RAG | LiveKit Documentation