I’m having trouble with Azure AI Agents when I try to import custom function tools from a different Python file. I have created some custom functions and put them in a ToolSet, but I get an error when the agent tries to use them.
Here’s my setup:
# In my tools file
custom_toolset = ToolSet()
my_functions = FunctionTool.from_defaults({
method1,
method2,
method3,
method4,
method5
})
custom_toolset.add(my_functions)
# In my main file
my_agent = project_client.agents.create_agent(
model=os.environ.get("AZURE_AOAI_CHAT_MODEL_NAME_DEPLOYMENT_ID"),
name="custom-tool-agent",
instructions="You can call custom functions when needed to help users.",
toolset=custom_toolset
)
The error I get is: ValueError: Toolset is not available in the client.
What’s weird is that if I put everything in one file, it works fine. The problem only happens when I import the ToolSet from another module. I’ve double checked that the import is working correctly and all the functions are defined properly.
Why does this happen when using separate files? Is there a way to fix this so I can keep my tools organized in a separate module?