Is it possible to execute a tool (for example, an API call or backend operation) in the background while the agent continues to handle ongoing user queries in real time?
More specifically, I’m trying to achieve a multitasking flow where:
A user request triggers a tool execution
The tool runs asynchronously (non-blocking)
Meanwhile, the agent continues the conversation with the user
Once the tool completes, the agent can return the result to the user
Does LiveKit provide built-in support or recommended patterns for this kind of concurrent tool execution within voice agents?
Use an async function tool to start the operation, immediately acknowledge it, and keep state in session/context. When the task completes, inject the result back into the session and have the agent speak it.
This aligns with LiveKit’s long-running tool example - agents/examples/voice_agents/long_running_function.py at main · livekit/agents · GitHub