if a tool call (over RPC) is a bit slow because it...
# ask-ai
a
if a tool call (over RPC) is a bit slow because it makes different async requests, what's the best way to handle it?
t
Thanks for reaching out, Sebastián. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking about handling a slow RPC tool call that performs multiple async requests — here are practical options you can use together to improve user experience and robustness. • Give immediate feedback: send a quick acknowledgement reply (e.g., "Working on that…") if the call takes > ~500ms so users know it’s active. • Show frontend progress: notify the UI via RPC to display a loading indicator or cancellable progress modal for long-running ops. • Send periodic status updates: emit intermediate messages (e.g., “Still fetching results…”) or partial results as sub-tasks complete. • Allow cancellation: make the frontend able to cancel the operation and surface that request to the tool so work can be aborted cleanly. • Use background cues (agent voice/audio): play a short “thinking” or typing sound while the tool runs to make delays feel natural. • Configure timeouts and retries: set
response_timeout
appropriate to expected work (longer for multi-request flows) and add retry/backoff for transient failures. • Return partial/streamed results: when possible stream results back as they arrive instead of waiting for all requests to finish. • Optimize parallelism and batching: run independent async requests in parallel and batch requests where the backend supports it to reduce overall latency. Which of these would you like implementation guidance for (client-side UI updates, RPC timeout config, streaming partial results, or cancellation handling)? Sources: External data and RAG | LiveKit Docs | Tool definition and use | LiveKit docs
a
the client side is voice only device, how would you send partial results of the tool call without fully acknoledging that tool call has finished?
t
Regarding sending partial results to a voice-only device without marking the tool call finished: • Send incremental voice replies as partial updates. Use
session.generate_reply()
for short status/partial-result utterances (e.g., “I’ve found the first item…,” “Working on more results…”). Emit these while the tool is still running so the client hears progress without the call being acknowledged as complete. • Stream results over RPC if your RPC supports streaming: push each partial result as it becomes available and avoid sending the final completion event until all work is done. • Use a distinct "in-progress" event or flag in your RPC messages so the client can play interim speech and keep the session open (examples:
status: "partial"
,
complete: false
). • Play background audio or a short “thinking” cue between partial replies to maintain conversational flow on voice devices. • Allow the client to cancel: expose a cancel signal the device can send; when received, stop further partial replies and send a final cancellation acknowledgement. • Keep partial replies short and informative so they don’t interrupt the user’s ability to listen or speak. Would you like a short code example for sending incremental
session.generate_reply()
updates or an example RPC message format for streaming partial results?