When an agent makes a tool call, how and when is t...
# ask-ai
w
When an agent makes a tool call, how and when is the tool call result added to the context?
t
Thanks for reaching out, Drew. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thank you for reaching out. Could you please provide more details about the issue you are experiencing? This will help us assist you better. Sources: External data and RAG | LiveKit Docs
w
I don't want my agent to make a reply after it calls a tool. I just want it to call the tool, then wait for the next user message before responding. How can I do that?
t
Hey there! If you want your agent to call a tool and then wait for the next message from the user before replying, here’s a simple way to do it: 1. Define the Tool: Start by using the
@function_tool
decorator to create a function that does exactly what you need. 2. Call the Tool: When your agent’s running, call that tool function. Just remember, don’t have it reply right away after the tool runs. 3. Wait for User Input: Use the session’s
generate_reply
method to pause and wait for the user’s next message before moving on. 4. Handle Context: The output from the tool will automatically be added to the chat history, so everything stays connected. This way, your agent can do its thing with the tool and then patiently wait for the user’s next message before continuing the chat. Pretty neat, right? Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Function calling with Voice Agents | LiveKit Docs