miniature-nail-35141
07/14/2025, 10:36 AMtall-airline-16756
07/14/2025, 10:36 AMtall-airline-16756
07/14/2025, 10:37 AMfunction_tool
(such as call_transfer
) in LiveKit. However, the examples demonstrate some common practices you can adopt:
• State Tracking: Before executing call_transfer
, check a local or session variable to ensure a transfer isn't already in progress.
• Conditional Logic: Perform validation at the start of your tool—such as verifying that a transfer has not already been initiated for the current session/context—to prevent repeated execution.
• Sequential Execution Model: Typical tool execution in LiveKit is sequential, meaning new tool calls wait for previous ones to finish; leverage this, but do not rely solely on it for idempotency.
You'll need to handle these safeguards in your function implementation; the system does not enforce idempotency or lock out duplicate calls automatically.
Sources: complex-agents/medical_office_triage/triage.py | examples/voice_agents/restaurant_agent.pyminiature-nail-35141
07/14/2025, 10:46 AMtall-airline-16756
07/14/2025, 10:47 AMfunction_tool
(like call_transfer
) is currently running. Think of it like tracking a friend's progress – we've got a few friendly ways to do this:
• Keep an ear out for the `FunctionToolsExecutedEvent`: It's like getting a notification when a task is complete. By watching which tool calls have finished, you can easily figure out which ones are still in the works.
• Agent State Checking: When the agent is in the thinking
state, it means a tool is being worked on. You can listen for agent_state_changed
events to get the full picture.
• Your Personal Tracking: For those special or longer-running tools, create a personal status flag (like is_transfer_running
) in your session. Think of it as your own little progress tracker – set it when something starts, and clear it once you know it's done.
Just between us, there's no straightforward public API to directly check running functions. But don't worry – by using completion events and keeping track of your own state, you'll be a pro at monitoring tool progress in no time!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Handling RAG Delays in Voice Agents | LiveKit Docs | telephony/warm_handoff.py