How do I ensure the function_tool gets called? The...
# ask-ai
m
How do I ensure the function_tool gets called? Theres redundant greeting / question from the instruyctions and session.say - what should be the correct way of passing question/prompt to a declarative_flow agent
t
Thanks for reaching out, Nikki. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're looking to ensure the
function_tool
gets called properly in a declarative_flow agent without those repetitive greetings or questions. Let's walk through some helpful steps together: • Write Clear Instructions: It's really important to provide precise instructions and docstrings. This helps guide the LLM on exactly when to invoke the tool, making everything run more smoothly. • Control Return Values: You can return
None
if you want the execution to be silent, or use
function_tools_executed
along with
cancel_tool_reply()
to prevent any automatic replies that might feel redundant. • Coordinate Speech: To avoid any overlap between
on_enter
and
session.say
, try sticking to just one method or control speech with the session state. This keeps the conversation flowing naturally. • Handle Transitions: When your tools return new
Agent
instances, it helps manage state changes gracefully without triggering extra LLM responses. • Track State: Using
session.state
or
session.userdata
is a great way to keep the flow consistent and prevent repeated actions that might confuse users. By following these tips, you'll create a more reliable and seamless experience for your agents in declarative workflows. If you have any questions or want to dive deeper into any of these points, feel free to ask—I'm here to help! Sources: Tool definition and use | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py | complex-agents/testing/agent.py | Pipeline nodes and hooks | LiveKit Docs