GovUK.Dfe.AI.Agents.AISearch 0.0.1-prerelease.316

Prefix Reserved
This is a prerelease version of GovUK.Dfe.AI.Agents.AISearch.
dotnet add package GovUK.Dfe.AI.Agents.AISearch --version 0.0.1-prerelease.316
                    
NuGet\Install-Package GovUK.Dfe.AI.Agents.AISearch -Version 0.0.1-prerelease.316
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GovUK.Dfe.AI.Agents.AISearch" Version="0.0.1-prerelease.316" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GovUK.Dfe.AI.Agents.AISearch" Version="0.0.1-prerelease.316" />
                    
Directory.Packages.props
<PackageReference Include="GovUK.Dfe.AI.Agents.AISearch" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GovUK.Dfe.AI.Agents.AISearch --version 0.0.1-prerelease.316
                    
#r "nuget: GovUK.Dfe.AI.Agents.AISearch, 0.0.1-prerelease.316"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GovUK.Dfe.AI.Agents.AISearch@0.0.1-prerelease.316
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GovUK.Dfe.AI.Agents.AISearch&version=0.0.1-prerelease.316&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=GovUK.Dfe.AI.Agents.AISearch&version=0.0.1-prerelease.316&prerelease
                    
Install as a Cake Tool

GovUK.Dfe.AI.Agents.AISearch

Gives your GovUK.Dfe.AI.Agents agents evidence from Azure AI Search. Results are numbered, so agents must cite them as [Evidence n].

Set up

dotnet add package GovUK.Dfe.AI.Agents.AISearch
"AiAgents": {
  "AISearch": {
    "Endpoint": "https://<search>.search.windows.net",
    "Indexes": [ { "Name": "ofsted_index", "ContentFields": [ "title", "content" ] } ]
  }
}
builder.Services.AddAgents(builder.Configuration, agents => agents
    .AddAgents(BriefingAgents.All)
    .AddAISearch());

Give the app's identity the Search Index Data Reader role. To use a different identity for search, add AISearch:Authentication, or set one in code with agents.UseAISearchCredential(credential).

Search without agents

An app that only needs search results, e.g. a search page, can add search on its own. It needs no Foundry settings and no agents:

builder.Services.AddAISearch(builder.Configuration, new ManagedIdentityCredential());

It reads the same AiAgents:AISearch section. Pass a credential, or leave it out and set a complete AiAgents:AISearch:Authentication block (TenantId, ClientId, ClientSecret). If you later add agents with agents.AddAISearch(), search is still registered only once.

Use

Inject IContextRetriever, search, and pass the result as evidence:

var evidence = await search.GetContextAsync("ofsted_index", $"Ofsted inspection {urn}", size: 10,
    filter: $"urn eq {urn}", cancellationToken: ct);

var result = await agents.RunAsync(BriefingAgents.Ofsted, "Summarise the latest inspection.", evidence, ct);

Pass the result itself, not evidence.Text, so its citation sources come with it.

  • Filter every search to the record you mean, e.g. one school. Relevance alone also returns similarly named ones.
  • Filters are escaped for you: write them as interpolated strings, and every {value} is escaped, so a value can't change what the filter matches. A plain or concatenated string won't compile. If you already have an escaped filter (e.g. from SearchFilter.Create), pass it with ODataFilter.Raw(filter).
  • Set ContentFields on each index. Otherwise every string field, including ids and URLs, is sent to the model.
  • Weak matches are dropped: results scoring below half the top score are removed. Change this with AISearch:MinimumRelevanceFilter (default 0.5).
  • Large results: evidence is capped at AISearch:MaxEvidenceCharacters (default 190,000, just under core's 200,000). Whole results are kept, most relevant first, and the rest are left out with a note, so no result is cut mid-way and citations still match. Raise both limits together for a larger model. To fetch less, lower size.

Citations

Agents cite results as [Evidence n]. Each one reaches your app as something a reader can use, with no settings:

The result has Rated Good [Evidence 1]. becomes
A field holding a full web address Rated Good [<a href="https://reports.ofsted.gov.uk/...">Copthorne School – Key Stage 2…</a>].
No web address Rated Good [Copthorne School – Key Stage 2…].
  • The text is the start of the result itself, on one line and cut at about 80 characters. Square brackets set each citation apart from the answer's own text.
  • The link is the first field whose whole value is a full https or http address. That field isn't sent to the model, so it can't write links itself. With ContentFields set, only those fields come back, so include the address field to get links.
  • No citations for an agent with RequiredCitations = false: they aren't asked for, and any the model writes are removed.
  • After the checks: citations change only once the answer passes, so each refers to real evidence. Validate and run observers still see [Evidence n].
  • Your app shows HTML: render the answer as HTML, or as Markdown that allows inline HTML. It's safe: the citation links are the only HTML in an answer, as any the model writes is shown as text.
  • Works for RunAsync, RunStreamingAsync and RunParallelAsync (return the search result from resolveEvidence). Evidence joined from several searches keeps [Evidence n], as their numbers would clash.

Keyword search misses documents that use different words, e.g. "safeguarding concerns" and "child protection issues". Set either or both of these on an index:

"Indexes": [ {
  "Name": "ofsted_index",
  "ContentFields": [ "title", "content" ],
  "SemanticConfiguration": "default",
  "VectorFields": [ "contentVector" ]
} ]
Setting Search type The index needs
Neither Keyword Nothing extra
SemanticConfiguration Keyword, re-ranked by meaning A semantic configuration, and the semantic ranker enabled (Basic tier or higher)
VectorFields Hybrid: keyword plus vector A vectorizer, so the service embeds the query (your app needs no embedding model)
Both Hybrid, re-ranked by meaning (best results) Both of the above

Your filter is applied before the vector search, so hybrid results still match only the record you asked about.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.1-prerelease.316 36 10/9/2026
0.0.1-prerelease.289 40 10/9/2026
0.0.1-prerelease.263 37 10/9/2026
0.0.1-prerelease.238 35 10/9/2026
0.0.1-prerelease.214 36 10/9/2026
0.0.1-prerelease.191 30 10/9/2026
0.0.1-prerelease.169 35 10/9/2026
0.0.1-prerelease.148 37 10/9/2026
0.0.1-prerelease.128 43 10/9/2026
0.0.1-prerelease.109 43 10/7/2026
0.0.1-prerelease.91 43 10/7/2026
0.0.1-prerelease.74 47 10/6/2026
0.0.1-prerelease.58 54 10/5/2026
0.0.1-prerelease.44 50 10/5/2026
0.0.1-prerelease.31 49 10/5/2026
0.0.1-prerelease.20 61 10/2/2026
0.0.1-prerelease.10 54 10/2/2026