able-jackal-19719
08/21/2025, 6:46 AMtall-airline-16756
08/21/2025, 6:46 AMtall-airline-16756
08/21/2025, 6:47 AMRunContext that’s available to tool functions. This way, the agent can finish its current message without getting interrupted.
Here’s a quick example:
@function_tool()
async def example_tool(self, ctx: RunContext):
# Disable interruptions for this function call
ctx.disallow_interruptions()
# Perform logic that generates speech
await self.session.say("This is an important instruction that should not be repeated.")
Also, if you want to prevent interruptions more broadly, you can set allow_interruptions=False in the agent’s configuration, which stops interruptions unless you specifically allow them.
Feel free to reach out if you want a hand setting this up or have any other questions!
Sources: basics/uninterruptable.py | livekit-agents/livekit/agents/voice/agent.pyable-jackal-19719
08/21/2025, 7:12 AMtall-airline-16756
08/21/2025, 7:12 AMable-jackal-19719
08/21/2025, 7:14 AMtall-airline-16756
08/21/2025, 7:15 AMtool_choice="none" right after the function runs. This way, the agent won’t circle back to those earlier instructions.
2. Control Reply Generation: You can use the reply_required flag in the function tool’s output to keep things quiet when no verbal response is needed. Just set generate_tool_reply=False if you want to skip the reply.
3. Manage Chat Context: Try not to keep adding the same instructions into the conversation context (chat_ctx) during or after the tool runs. Only update the instructions when it’s really necessary.
4. Preserve Context Integrity: If you’re switching tasks or agents, make sure to pass along the full chat_ctx so the conversation flows smoothly without repeating old instructions.
Give these a shot, and they should help clear things up! If you want a hand setting any of this up, just let me know—I’m here to help.
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | Workflows | LiveKit Docs