I'm working with Azure AI Agents and trying to use custom functions within an agent. I've defined several user-defined functions and wrapped them using FunctionTool
, then added them to a ToolSet
. Here's how I've structured my code:
{
func1,
func2,
func3,
func4,
func5
})
func_fetching_toolset = ToolSet()
func_fetching_toolset.add(functions_tool)
agent = project_client.agents.create_agent(
model=os.environ.get("AZURE_AOAI_CHAT_MODEL_NAME_DEPLOYMENT_ID"),
name="func-fetching-agent",
instructions="""
You are an advanced assistant capable of calling user-defined functions when necessary.
""",
toolset=func_fetching_toolset,
)
When I create a thread and run it, I encounter the following error:
ValueError: Toolset is not available in the client.
Observations:
tools.py
and main.py
), the error does not occur, and everything works as expected.ToolSet
is defined in one module and used in another.My Question:
ValueError: Toolset is not available in the client.
error when the agent is created in a different file from where the ToolSet
is defined?ToolSet
defined in one module (tools.py
) within an agent created in another module (main.py
)?What I've Tried:
func_fetching_toolset
is correctly imported into main.py
.ToolSet
and FunctionTool
are correctly constructed.I too was having this very issue and the thing that solved it for me was passing the toolset while creating the run.
project_client.agents.create_and_process_run(thread_id=thread.id, assistant_id=agent.id, toolset=toolset)