if i update tools dynamically using update_tool() ...
# ask-ai
a
if i update tools dynamically using update_tool() for an Agent, will it still have access of the previous tools that were provided to it?
t
Thanks for reaching out, Aditya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I’m happy to help explain how the
update_tools()
method works! This method replaces the agent’s current tools with the new set you provide. Just a quick heads-up: it doesn’t keep the old tools unless you specifically include them in the new list. If you want to keep your existing tools and just add or remove certain ones, here’s a friendly way to do that:
Copy code
# Add a new tool while keeping existing ones
await agent.update_tools(agent.tools + [new_tool])

# Remove a specific tool
await agent.update_tools([t for t in agent.tools if t.name != "tool_to_remove"])
This way, you can make sure your agent holds on to the tools you want while still updating its capabilities. If you have any questions or need more help, feel free to ask! Sources: Tool definition and use | LiveKit docs | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Agent Session & Client Integration | livekit/livekit_composite | DeepWiki
a
what to do if i want to replace the entire set of tools
t
If you'd like to replace the entire set of tools, you can easily do so by calling the
update_tools()
method with your new list of tools. This will gently overwrite the existing tools with the fresh set you provide. For example:
Copy code
# Replace the entire set of tools
await agent.update_tools([new_tool1, new_tool2, new_tool3])
This way, you can be confident that only the tools you've specified in the new list will be available to the agent. If you have any questions along the way, I'm here to help!