Azure / Azure/azure-sdk-for-python
Tool call of AzureAISearchTool doesn't respect tool configuration such as `filter` and `top_k` in package `azure-ai-agents`
- 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.0.2
- **Operating System**: Linux
- **Python Version**: 3.11.5
**Describe the bug**
```python
toolset = ToolSet()
conn_id = project_client.connections.get_default(ConnectionType.AZURE_AI_SEARCH).id
azure_ai_search_tool = AzureAISearchTool(
index_connection_id=conn_id,
index_name="garen-markdown-rag",
query_type=AzureAISearchQueryType.SEMANTIC,
top_k=10,
filter="project_id eq 'f030e809-b27b-42a7-913d-7fafcf5f3f38' and search.in(source_id, '4040a8c4-b17e-4d1e-8ecb-308ef6ee9a3a')",
)
toolset.add(azure_ai_search_tool)
run = project_client.agents.runs.create_and_process(
thread_id=thread_id,
agent_id=agent_id,
tool_choice={"type": "azure_ai_search"},
toolset=toolset
)
if run.status == "failed":
raise AzureClientError(f"Run failed: {run.last_error}")
run_steps = project_client.agents.run_steps.list(thread_id=thread_id, run_id=run.id)
for step in run_steps:
if step.step_details.type == "tool_calls":
for call in step.step_details.get("tool_calls" , []):
logger.info(f"azure_ai_search_details: {call.get('azure_ai_search', {})}\n")
```
The log showing the details of the tool call has the following output:
```json
{
"input": "Tell me a joke",
"output": {
"summary": "Retrieved 0 documents.",
"metadata": {
"urls": [],
"titles": [],
"get_urls": [],
"ids": [],
"command": "search",
"query_type": "semantic",
"top_k": 5,
"filter": false
}
}
}
```
As shown in the log, the tool call didn't respect the configuration set on `AzureAISearchTool` when attaching it to the `run`. The `top_k` set on the tool was `10`, but the call used `5`. Also, a `filter` was set on the tool but the call didn't apply it
**To Reproduce**
Steps to reproduce the behavior:
1.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.
Contributor guide
Assessment
This issue has not been assessed yet.