Azure / Azure/azure-sdk-for-python

Failed to add multiple AzureAISearchTools in ToolSet

Open
#41,498 6 comments 0 reactions 1 assignee Assigned to @glharper View on GitHub
AI Agents Client customer-reported feature-request needs-team-attention question
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

Description

- **Package Name**: azure-ai-agents
- **Package Version**: 1.1.0b1
- **Operating System**: Ubuntu 22.04
- **Python Version**: 3.10.12

**Describe the bug**
I have several Azure AI Search indexes, each responsible for a different set of knowledge. I would like to convert these AI Search indexes into tools, so that my AI Agent can use the appropriate tool (i.e., index) depending on the specific task.

I tried adding these tools using ToolSet, but I encountered the following error:
```
Traceback (most recent call last):
File "/workspace/Azure_Agent/61_Agent_ToolSet.py", line 98, in
toolset.add(ai_search_tool2)
File "/usr/local/lib/python3.10/dist-packages/azure/ai/agents/models/_patch.py", line 1206, in add
raise ValueError("Tool of type {type(tool).__name__} already exists in the ToolSet.")
ValueError: Tool of type {type(tool).__name__} already exists in the ToolSet.
```

Here is my code:
```
ai_search_tool1 = AzureAISearchTool(
index_connection_id="xxx",
index_name="index1",
query_type=AzureAISearchQueryType.VECTOR_SEMANTIC_HYBRID,
top_k=3,
filter=""
)
ai_search_tool2 = AzureAISearchTool(
index_connection_id="xxx",
index_name="index2",
query_type=AzureAISearchQueryType.VECTOR_SEMANTIC_HYBRID,
top_k=3,
filter=""
)

toolset = ToolSet()
toolset.add(ai_search_tool1)
toolset.add(ai_search_tool2)

with agents_client:
agent = agents_client.create_agent(
model="gpt-4o",
name="agent-sdk-kk-with-toolset",
instructions="You are a helpful agent. To answer user question, you can use tools to retrieve information from diff AI Search Tools",
toolset=toolset,
)

```
Could you please help me understand how to properly configure this setup, or let me know if there are any limitations I should be aware of?

Thank you in advance for your assistance.

Kevin Kuei
**To Reproduce**
Steps to reproduce the behavior:
1. check the code snippets

**Expected behavior**
Agent can use multiple AzureAISearch tools

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.