What is the best way to ensure that an agent says ...
# ask-ai
w
What is the best way to ensure that an agent says something when its calling a tool, but also that its not repeating itself since LLMs can return both a tool call and text response in the same response? Is there any way to say in the function_tool "generate a response if the agent isn't currently speaking"?
t
Thanks for reaching out, Alex. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help your agent avoid repeating itself when calling a tool and generating a response at the same time, you can set things up so it handles tool execution and response generation one after the other. Here are a few friendly tips to get you started: • Repetition Control: Try using repetition penalties in the model settings to gently discourage the agent from repeating itself. • Sequential Tool Execution: Configure the agent to process tool calls and responses step-by-step, making sure one finishes before the next begins. • System Prompt Configuration: Add clear instructions in the system prompt to keep things concise and avoid repetition. • Speech Handle Management: Take advantage of LiveKit’s speech handle system to manage overlapping speech and interrupt previous responses when new tool calls come in. These tweaks help the agent recognize when a tool’s been used and keep responses neat and non-redundant. If you want, I’m happy to share some detailed examples or help you set this up! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Together AI LLM integration guide | LiveKit Docs | Perplexity LLM integration guide | LiveKit Docs