Skip to content

Commit b9e0187

Browse files
authored
Merge pull request #5107 from HeidiSteen/heidist-work
Edits based on MattG updates
2 parents 4dfa703 + 8fdd29d commit b9e0187

File tree

4 files changed

+132
-53
lines changed

4 files changed

+132
-53
lines changed

articles/search/includes/quickstarts/agentic-retrieval-python.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ ms.date: 05/12/2025
99

1010
[!INCLUDE [Feature preview](../previews/preview-generic.md)]
1111

12-
In this quickstart, you use [agentic retrieval](../../search-agentic-retrieval-concept.md) to create a conversational search experience powered by large language models (LLMs) and your proprietary data. Agentic retrieval breaks down complex user queries into subqueries, runs the subqueries in parallel, and extracts grounding data from documents indexed in Azure AI Search. The output is intended for integration with custom chat solutions.
12+
In this quickstart, you use [agentic retrieval](../../search-agentic-retrieval-concept.md) to create a conversational search experience powered by large language models (LLMs) and your proprietary data. Agentic retrieval breaks down complex user queries into subqueries, runs the subqueries in parallel, and extracts grounding data from documents indexed in Azure AI Search. The output is intended for integration with agentic and custom chat solutions.
1313

1414
Although you can provide your own data, this quickstart uses [sample JSON documents](https://github.com/Azure-Samples/azure-search-sample-data/tree/main/nasa-e-book/earth-at-night-json) from NASA's Earth at Night e-book. The documents describe general science topics and images of Earth at night as observed from space.
1515

16+
This quickstart is based on the [Quickstart-Agentic-Retrieval](https://github.com/Azure-Samples/azure-search-python-samples/tree/main/Quickstart-Agentic-Retrieval) Jupyter notebook on GitHub.
17+
1618
## Prerequisites
1719

1820
+ An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
@@ -66,7 +68,7 @@ To configure the recommended role-based access:
6668

6769
1. On your Azure AI Search service, [assign the following roles](../../search-security-rbac.md#how-to-assign-roles-in-the-azure-portal) to yourself.
6870

69-
+ **Owner/Contributor** or **Search Service Contributor**
71+
+ **Search Service Contributor**
7072

7173
+ **Search Index Data Contributor**
7274

articles/search/includes/quickstarts/agentic-retrieval-rest.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ POST {{baseUrl}}/indexes/{{index-name}}/docs/index?api-version={{api-version}}
279279
}
280280
```
281281

282-
## Create a search agent
282+
## Create a knowledge agent
283283

284-
To connect Azure AI Search to your `gpt-4o-mini` deployment and target the `earth_at_night` index at query time, you need a search agent. Use [Create Knowledge Agents](/rest/api/searchservice/knowledge-agents/create?view=rest-searchservice-2025-05-01-preview&preserve-view=true) to define an agent named `earth-search-agent`, which you specified using the `@agent-name` variable in a previous section.
284+
To connect Azure AI Search to your `gpt-4o-mini` deployment and target the `earth_at_night` index at query time, you need a knowledge agent. Use [Create Knowledge Agents](/rest/api/searchservice/knowledge-agents/create?view=rest-searchservice-2025-05-01-preview&preserve-view=true) to define an agent named `earth-search-agent`, which you specified using the `@agent-name` variable in a previous section.
285285

286286
To ensure relevant and semantically meaningful responses, `defaultRerankerThreshold` is set to exclude responses with a reranker score of `2.5` or lower.
287287

articles/search/search-agentic-retrieval-how-to-pipeline.md

Lines changed: 125 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: HeidiSteen
88
ms.author: heidist
99
ms.service: azure-ai-search
1010
ms.topic: how-to
11-
ms.date: 05/10/2025
11+
ms.date: 05/21/2025
1212
---
1313

1414
# Build an agent-to-agent retrieval solution using Azure AI Search
@@ -19,30 +19,80 @@ This article describes an approach or pattern for building a solution that uses
1919

2020
This article supports the [agentic-retrieval-pipeline-example](https://github.com/Azure-Samples/azure-search-python-samples/tree/main/agentic-retrieval-pipeline-example) Python sample on GitHub.
2121

22-
This exercise differs from the [Agentic Retrieval Quickstart](search-get-started-agentic-retrieval.md) in how it uses Azure AI Agent to determine whether to retrieve data from the index, and how it uses an agent tool for orchestration.
22+
This exercise differs from the [Agentic Retrieval Quickstart](search-get-started-agentic-retrieval.md) in how it uses Azure AI Agent to retrieve data from the index, and how it uses an agent tool for orchestration. If you want to understand the retrieval pipeline in its simplest form, begin with the quickstart.
2323

2424
## Prerequisites
2525

2626
The following resources are required for this design pattern:
2727

28-
+ Azure AI Search, basic tier or higher, in a [region that provides semantic ranker](search-region-support.md).
28+
+ Azure AI Search, basic tier or higher, in a [region that provides semantic ranking](search-region-support.md).
2929

3030
+ A search index that satisfies the [index criteria for agentic retrieval](search-agentic-retrieval-how-to-index.md).
3131

32-
+ Azure OpenAI, and you should have an **Azure AI Developer** role assignment to create a Foundry project.
32+
+ A project in Azure AI Foundry, with an Azure AI Agent in a Basic setup.
3333

34-
+ A project in Azure AI Foundry, with a deployment of a supported large language model and an Azure AI Agent in a basic setup. To meet this requirement, follow the steps in [Quickstart: Create a new agent (Preview)](/azure/ai-services/agents/quickstart?pivots=ai-foundry-portal). We recommend 100,000 token capacity for your model. You can find capacity and the rate limit in the model deployments list in the Azure AI Foundry portal.
34+
Follow the steps in [Create a project for Azure AI Foundry](/azure/ai-foundry/how-to/create-projects). Creating the project also creates the Azure AI Foundry resource in your Azure subscription.
35+
36+
+ Azure OpenAI with a deployment of one of the chat completion models listed below. We recommend a minimum of 100,000 token capacity for your model. You can find capacity and the rate limit in the model deployments list in the Azure AI Foundry portal. You can also deploy text embedding models if you want [vectorization at query time](vector-search-integrated-vectorization.md#using-integrated-vectorization-in-queries).
3537

3638
### Supported large language models
3739

38-
Use Azure OpenAI or an equivalent open source model:
40+
Use one of the following chat completion models with your AI agent:
3941

4042
+ `gpt-4o`
4143
+ `gpt-4o-mini`
4244
+ `gpt-4.1`
4345
+ `gpt-4.1-nano`
4446
+ `gpt-4.1-mini`
4547

48+
### Package version requirements
49+
50+
Use a package version that provides preview functionality. See the [`requirements.txt`](https://github.com/Azure-Samples/azure-search-python-samples/blob/main/agentic-retrieval-pipeline-example/requirements.txt) file for more packages used in the example solution.
51+
52+
```
53+
azure-ai-projects==1.0.0b11
54+
azure-ai-agents==1.0.0
55+
azure-search-documents==11.6.0b12
56+
```
57+
58+
### Configure access
59+
60+
Before you begin, make sure you have permissions to access content and operations. We recommend Microsoft Entra ID authentication and role-based access for authorization. You must be an **Owner** or **User Access Administrator** to assign roles. If roles aren't feasible, you can use [key-based authentication](search-security-api-keys.md) instead.
61+
62+
Configure access to each resource identified in this section.
63+
64+
### [**Azure AI Search**](#tab/search-perms)
65+
66+
Azure AI Search provides the agentic retrieval pipeline. Configure access for yourself, your app, and your search service for downstream access to models.
67+
68+
1. [Enable role-based access](search-security-enable-roles.md).
69+
1. [Configure a managed identity](search-howto-managed-identities-data-sources.md).
70+
1. [Assign roles](search-security-rbac.md):
71+
72+
+ For local testing, you must have **Search Service Contributor**, **Search Index Data Contributor**, and **Search Index Data Reader** role assignments to create, load, and retrieve on Azure AI Search.
73+
74+
+ For integrated operations, ensure that all clients using the retrieval pipeline (agent and tool) have **Search Index Data Reader** role assignments for sending retrieval requests.
75+
76+
### [**Azure AI Foundry**](#tab/foundry-perms)
77+
78+
Azure AI Foundry hosts the AI agent and tool. Permissions are needed to create and use the resource.
79+
80+
+ You must be an **Owner** of your Azure subscription to create the project and resource.
81+
82+
+ For local testing, you must be an **Azure AI User** to access chat completion models deployed to the Foundry resource. This assignment is conferred automatically for **Owners** when you create the resource. Other users need a specific role assignment. For more information, see [Role-based access control in Azure AI Foundry portal](/azure/ai-foundry/concepts/rbac-azure-ai-foundry).
83+
84+
+ For integrated operations, ensure your [search service identity](search-howto-managed-identities-data-sources.md) has an **Azure AI User** role assignment on the Foundry resource.
85+
86+
### [**Azure OpenAI**](#tab/openai-perms)
87+
88+
Azure OpenAI hosts the models used by the agentic retrieval pipeline. Configure access for yourself and for the search service.
89+
90+
+ For local testing, ensure that you have a **Cognitive Services User** role assignment to access the chat completion model and embedding models (if using).
91+
92+
+ For integrated operations, ensure your [search service identity](search-howto-managed-identities-data-sources.md) has a **Cognitive Services User** role assignment for model access.
93+
94+
---
95+
4696
## Development tasks
4797

4898
Development tasks on the Azure AI Search side include:
@@ -55,25 +105,13 @@ Development tasks on the Azure AI Search side include:
55105

56106
Your custom application makes API calls to Azure AI Search and an Azure SDK.
57107

58-
+ External data from anywhere
59-
+ Azure AI Search, hosting indexed data and the agentic data retrieval engine
60-
+ Azure AI Foundry Model, providing a chat model (an LLM) for user interaction
61-
+ Azure SDK with a Foundry project, providing programmatic access to chat and chat history
62-
+ Azure AI Agent, with an agent for handling the conversation, and a tool for orchestration
63-
64-
## How to customize grounding data
65-
66-
Search results are consolidating into a large unified string that you can pass to a conversational language model for a grounded answer. The following indexing and relevance tuning features in Azure AI Search are available to help you generate high quality results:
108+
+ External data from anywhere, although we recommend [data sources used for integrated indexing](search-data-sources-gallery.md).
109+
+ Azure AI Search, hosting indexed data and the agentic data retrieval engine.
110+
+ Azure AI Foundry, hosting the AI agent and tool.
111+
+ Azure SDK with a Foundry project, providing programmatic access to Azure AI Foundry.
112+
+ Azure OpenAI, hosting a chat completion model used by the knowledge agent and any embedding models used by vectorizers for vector search.
67113

68-
+ Scoring profiles (added to your search index) provide built-in boosting criteria. Your index must specify a default scoring profile, and that's the one used by the retrieval engine when queries include fields associated with that profile.
69-
70-
+ Semantic configuration is required, but you determine which fields are prioritized and used for ranking.
71-
72-
+ For plain text content, you can use analyzers to control tokenization during indexing.
73-
74-
+ For multimodal or image content, you can use image verbalization for LLM-generated descriptions of your images, or classic OCR and image analysis via skillsets during indexing.
75-
76-
## Create the project
114+
## Set up your environment
77115

78116
The canonical use case for agentic retrieval is through the Azure AI Agent service. We recommend it because it's the easiest way to create a chatbot.
79117

@@ -85,29 +123,73 @@ You need endpoints for:
85123
+ Azure OpenAI
86124
+ Azure AI Foundry project
87125

88-
You can find endpoints for Azure AI Search and Azure OpenAI in the [Azure portal](https://portal.azure.com).
126+
You can find endpoints for Azure AI Search and Azure OpenAI in the [Azure portal](https://portal.azure.com), in the **Overview** pages for each resource.
89127

90-
You can find the project connection string in the Azure AI Foundry portal:
128+
You can find the project endpoint in the Azure AI Foundry portal:
91129

92130
1. Sign in to the [Azure AI Foundry portal](https://ai.azure.com) and open your project.
93131

94-
1. In the **Project details** tile, find and copy the **Project connection string**.
95-
96-
A hypothetical connection string might look like this: `eastus2.api.azureml.ms;00000000-0000-0000-0000-0000000000;rg-my-resource-group-name;my-foundry-project-name`
132+
1. In the **Overview** tile, find and copy the Azure AI Foundry project endpoint.
97133

98-
1. Check the authentication type for your Azure OpenAI resource and make sure it uses an API key shared to all projects. Still in **Project details**, expand the **Connected resources** tile to view the authentication type for your Azure OpenAI resource.
134+
A hypothetical endpoint might look like this: `https://your-foundry-resource.services.ai.azure.com/api/projects/your-foundry-project`
99135

100136
If you don't have an Azure OpenAI resource in your Foundry project, revisit the model deployment prerequisite. A connection to the resource is created when you deploy a model.
101137

138+
### Set up an AI project client and create an agent
139+
140+
Use [AIProjectClient](/python/api/azure-ai-projects/azure.ai.projects.aiprojectclient?view=azure-python-preview&preserve-view=true) to create your AI agent.
141+
142+
```python
143+
from azure.ai.projects import AIProjectClient
144+
145+
project_client = AIProjectClient(endpoint=project_endpoint, credential=credential)
146+
147+
list(project_client.agents.list_agents())
148+
```
149+
150+
Your agent is backed by a supported language model and instructions inform the agent of its scope.
151+
152+
```python
153+
instructions = """
154+
A Q&A agent that can answer questions about the Earth at night.
155+
Sources have a JSON format with a ref_id that must be cited in the answer using the format [ref_id].
156+
If you do not have the answer, respond with "I don't know".
157+
"""
158+
agent = project_client.agents.create_agent(
159+
model=agent_model,
160+
name=agent_name,
161+
instructions=instructions
162+
)
163+
164+
print(f"AI agent '{agent_name}' created or updated successfully")
165+
```
166+
102167
### Add an agentic retrieval tool to AI Agent
103168

104169
An end-to-end pipeline needs an orchestration mechanism for coordinating calls to the retriever and knowledge agent. You can use a [tool](/azure/ai-services/agents/how-to/tools/function-calling) for this task. The tool calls the Azure AI Search knowledge retrieval client and the Azure AI agent, and it drives the conversations with the user.
105170

106-
## How to design a prompt
171+
```python
172+
from azure.ai.agents.models import FunctionTool, ToolSet, ListSortOrder
173+
174+
from azure.search.documents.agent import KnowledgeAgentRetrievalClient
175+
from azure.search.documents.agent.models import KnowledgeAgentRetrievalRequest, KnowledgeAgentMessage, KnowledgeAgentMessageTextContent, KnowledgeAgentIndexParams
107176

108-
The prompt sent to the LLM includes instructions for working with the grounding data, which is passed as a large single string with no serialization or structure.
177+
agent_client = KnowledgeAgentRetrievalClient(endpoint=endpoint, agent_name=agent_name, credential=credential)
109178

110-
The tool or function that you use to drive the pipeline provides the instructions to the LLM for the conversation.
179+
thread = project_client.agents.threads.create()
180+
retrieval_results = {}
181+
182+
# AGENTIC RETRIEVAL DEFINITION DEFERRED TO NEXT SECTION
183+
184+
functions = FunctionTool({ agentic_retrieval })
185+
toolset = ToolSet()
186+
toolset.add(functions)
187+
project_client.agents.enable_auto_function_calls(toolset)
188+
```
189+
190+
## How to structure messages
191+
192+
The messages sent to the agent tool include instructions for chat history and using the results obtained from [knowledge retrieval](/rest/api/searchservice/knowledge-retrieval/retrieve?view=rest-searchservice-2025-05-01-preview&preserve-view=true) on Azure AI Search. The response is passed as a large single string with no serialization or structure.
111193

112194
```python
113195
def agentic_retrieval() -> str:
@@ -135,22 +217,17 @@ def agentic_retrieval() -> str:
135217
return retrieval_result.response[0].content[0].text
136218
```
137219

138-
To provide instructions used for building the query plan and the subqueries used to get the grounding data, set the message in the knowledge agent:
220+
## How to improve data quality
139221

140-
```python
141-
project_client = AIProjectClient.from_connection_string(project_conn_str, credential=credential)
222+
Search results are consolidated into a large unified string that you can pass to a chat completion model for a grounded answer. The following indexing and relevance tuning features in Azure AI Search are available to help you generate high quality results. You can implement these features in the search index, and the improvements in search relevance are evident in the quality of the response returned during retrieval.
142223

143-
instructions = """
144-
An Q&A agent that can answer questions about the Earth at night.
145-
Sources have a JSON format with a ref_id that must be cited in the answer.
146-
If you do not have the answer, respond with "I don't know".
147-
"""
148-
agent = project_client.agents.create_agent(
149-
model=agent_model,
150-
name=agent_name,
151-
instructions=instructions
152-
)
153-
```
224+
+ [Scoring profiles](index-add-scoring-profiles.md) (added to your search index) provide built-in boosting criteria. Your index must specify a default scoring profile, and that's the one used by the retrieval engine when queries include fields associated with that profile.
225+
226+
+ [Semantic configuration](semantic-how-to-configure.md) is required, but you determine which fields are prioritized and used for ranking.
227+
228+
+ For plain text content, you can use [analyzers](index-add-custom-analyzers.md) to control tokenization during indexing.
229+
230+
+ For [multimodal or image content](multimodal-search-overview.md), you can use image verbalization for LLM-generated descriptions of your images, or classic OCR and image analysis via skillsets during indexing.
154231

155232
## Control the number of subqueries
156233

@@ -178,7 +255,7 @@ Look at output tokens in the [activity array](search-agentic-retrieval-how-to-re
178255

179256
+ Summarize message threads.
180257

181-
+ Use `gpt mini`.
258+
+ Use `gpt mini` or a smaller model that performs faster.
182259

183260
+ Set `maxOutputSize` in the [knowledge agent](search-agentic-retrieval-how-to-create.md) to govern the size of the response, or `maxRuntimeInSeconds` for time-bound processing.
184261

articles/search/search-query-access-control-rbac-enforcement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The end-user application sends user permission as part of the search query reque
4343

4444
Azure AI Search dynamically constructs security filters based on the user permissions provided. These security filters are automatically appended to any filters that might come in with the query if the index has the permission filter option enabled.
4545

46-
For Azure RBAC, permissions are lists of resource ID strings, and there must be an Azure role assignment (Storage Blob Data Reader) on the data the source that grants access to the security principal token in the authorization header. The filter excludes documents if there's no role assignment for the principal behind the access token on the request.
46+
For Azure RBAC, permissions are lists of resource ID strings. There must be an Azure role assignment (Storage Blob Data Reader) on the data the source that grants access to the security principal token in the authorization header. The filter excludes documents if there's no role assignment for the principal behind the access token on the request.
4747

4848
### 3. Results filtering
4949

0 commit comments

Comments
 (0)